|
| 1 | + |
| 2 | +function sayMyName(){ |
| 3 | + console.log("N"); |
| 4 | + console.log("A"); |
| 5 | + console.log("I"); |
| 6 | + console.log("N"); |
| 7 | + console.log("I"); |
| 8 | +} |
| 9 | + |
| 10 | +//sayMyName() |
| 11 | + |
| 12 | +// function addTwoNumbers(number1, number2){ |
| 13 | + |
| 14 | +// console.log(number1 + number2); |
| 15 | +// } |
| 16 | + |
| 17 | +function addTwoNumbers(number1, number2){ |
| 18 | + |
| 19 | + // let result = number1 + number2 |
| 20 | + // return result |
| 21 | + return number1 + number2 |
| 22 | +} |
| 23 | + |
| 24 | +const result = addTwoNumbers(3, 5) |
| 25 | + |
| 26 | +// console.log("Result: ", result); |
| 27 | + |
| 28 | +function loginUserMessage(username= "sam"){ |
| 29 | + if(!username){ |
| 30 | + console.log("Please enter a username"); |
| 31 | + return |
| 32 | + } |
| 33 | + return `${username} just logged in` |
| 34 | +} |
| 35 | +//console.log(loginUserMessage("naini")); |
| 36 | +//console.log(loginUserMessage()); |
| 37 | + |
| 38 | +function calculateCartPrice(val1, val2, ...num1){ //rest operator |
| 39 | + return num1 |
| 40 | +} |
| 41 | + |
| 42 | +// console.log(calculateCartPrice(200, 400, 500, 2000)); |
| 43 | + |
| 44 | +const user = { |
| 45 | + username: "hitesh", |
| 46 | + prices: 199 |
| 47 | +} |
| 48 | + |
| 49 | +function handleObject(anyobject){ |
| 50 | + console.log(`Username is ${anyobject.username} and price is ${anyobject.price}`); |
| 51 | +} |
| 52 | + |
| 53 | +// handleObject(user) |
| 54 | +handleObject({ |
| 55 | + username: "sam", |
| 56 | + price: 399 |
| 57 | +}) |
| 58 | + |
| 59 | +const myNewArray = [200, 400, 100, 600] |
| 60 | + |
| 61 | +function returnSecondValue(getArray){ |
| 62 | + return getArray[1] |
| 63 | +} |
| 64 | + |
| 65 | +// console.log(returnSecondValue(myNewArray)); |
| 66 | +console.log(returnSecondValue([200, 400, 500, 1000])); |
0 commit comments