Skip to content

Commit bd96e37

Browse files
committed
Functions in javascript
1 parent 762a28d commit bd96e37

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

03_basics/01_functions.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,30 @@ function loginUserMessage(username){
3939
}
4040

4141
console.log(loginUserMessage("hitesh"))//hitesh just logged in
42-
console.log(loginUserMessage())//undefined just logged in
42+
console.log(loginUserMessage())//undefined just logged in
43+
44+
function calculateCartPrice(...num1){
45+
return num1
46+
}
47+
console.log(calculateCartPrice(200, 400, 500, 2000))//[ 200, 400, 500, 2000 ]
48+
49+
const user = {
50+
username: "hitesh",
51+
price: 199
52+
}
53+
54+
function handleObject(anyObject){
55+
console.log(`Username is ${anyObject.username} and price is ${anyObject.price}`);
56+
}
57+
handleObject(user)//Username is hitesh and price is 199
58+
handleObject({
59+
username: "sam",
60+
price: 399
61+
})//Username is sam and price is 399
62+
63+
const myNewArray = [200, 400, 100, 600];
64+
function returnSecondValue(getArray){
65+
return getArray[1]
66+
}
67+
console.log(returnSecondValue(myNewArray));//400
68+
console.log(returnSecondValue([200, 400, 500, 1000]))//400

0 commit comments

Comments
 (0)