|
| 1 | +// "use strict"; |
| 2 | + |
| 3 | +// const products = { |
| 4 | +// 1: { |
| 5 | +// img: "", |
| 6 | + |
| 7 | +// }, |
| 8 | +// 2: { |
| 9 | +// img: "", |
| 10 | + |
| 11 | +// }, |
| 12 | +// 3: { |
| 13 | +// img: "1342422", |
| 14 | +// name:"", |
| 15 | +// description:"", |
| 16 | +// // ... |
| 17 | +// }, |
| 18 | +// 4: { |
| 19 | +// img: "", |
| 20 | + |
| 21 | +// }, |
| 22 | +// 5: { |
| 23 | +// img: "", |
| 24 | + |
| 25 | +// }, |
| 26 | +// }; |
| 27 | + |
| 28 | +// // functions |
| 29 | + |
| 30 | +// console.log("Hello") // method |
| 31 | + |
| 32 | +// alert() |
| 33 | +// prompt() |
| 34 | + |
| 35 | +// function sayHello(){ |
| 36 | +// console.log("Hello world!") |
| 37 | +// } |
| 38 | + |
| 39 | +// sayHello() |
| 40 | + |
| 41 | +// // (a,b) |
| 42 | + |
| 43 | +// const saySomething = function(){ |
| 44 | +// console.log("WDHVUWIDHVJBEROBJBRE") |
| 45 | +// } |
| 46 | + |
| 47 | +// saySomething() |
| 48 | + |
| 49 | +// const sayHi = function Hi() { |
| 50 | +// console.log("hi"); |
| 51 | +// }; |
| 52 | + |
| 53 | +// console.log(sayHi()); |
| 54 | +// console.log(Hi()); |
| 55 | + |
| 56 | +// var object1 = {}; |
| 57 | +// let object2 = { |
| 58 | +// hi: "hello", |
| 59 | +// }; |
| 60 | + |
| 61 | +// const object3 = { |
| 62 | +// hi: "hello", |
| 63 | +// }; |
| 64 | + |
| 65 | +// console.log((object2.hi = "HIIIIIII")); |
| 66 | +// console.log((object3.hi = "HIIIIIII")); |
| 67 | + |
| 68 | +// const name = prompt() |
| 69 | + |
| 70 | +// const sayHi = function (name) { |
| 71 | +// console.log("Hi " + name); |
| 72 | +// return true |
| 73 | +// }; |
| 74 | + |
| 75 | +// console.log(sayHi(name)) |
| 76 | + |
| 77 | +// function multiply(a, b) { |
| 78 | +// console.log("a:", a, "b:", b); |
| 79 | +// // const c = a * b; |
| 80 | +// console.log(a * b); |
| 81 | +// // return c |
| 82 | +// } |
| 83 | + |
| 84 | +// // multiply(2, 5) |
| 85 | +// multiply("2", "5"); |
| 86 | + |
| 87 | +// function multiply2(x, y) { |
| 88 | +// if (x > 10 || y > 10) { |
| 89 | +// return("a or b is greater than 10") |
| 90 | +// } else { |
| 91 | +// return x * y; |
| 92 | +// } |
| 93 | +// } |
| 94 | + |
| 95 | +// console.log(multiply2(10,4)) |
| 96 | + |
| 97 | +// const user = { |
| 98 | +// name: "amin", |
| 99 | +// password: "12345", |
| 100 | +// }; |
| 101 | + |
| 102 | +// function karbar(name, password) { |
| 103 | +// if (name == user.name && password == user.password) { |
| 104 | +// // console.log("welcome"); |
| 105 | +// return "welcome"; |
| 106 | +// } else { |
| 107 | +// // console.log("try again"); |
| 108 | +// return "try again"; |
| 109 | +// } |
| 110 | +// } |
| 111 | +// console.log(karbar("amin",12345)); |
| 112 | + |
| 113 | +// function scoreCheck(score) { |
| 114 | +// if (score === 100) { |
| 115 | +// return "S 🎉"; |
| 116 | +// } else if (score >= 80) { |
| 117 | +// return "A 🧠"; |
| 118 | +// } else if (score >= 60) { |
| 119 | +// return "B 🎈"; |
| 120 | +// } else if (score >= 40) { |
| 121 | +// return "C 😐"; |
| 122 | +// } else if (score >= 20) { |
| 123 | +// return "D 🤬"; |
| 124 | +// } |
| 125 | +// } |
| 126 | + |
| 127 | +// // console.log(scoreCheck(100)) |
| 128 | + |
| 129 | +// let score = +prompt("score") |
| 130 | +// console.log(scoreCheck(score)) |
| 131 | + |
| 132 | +// let score1 = prompt("score 1") |
| 133 | + |
| 134 | +// console.log(typeof score) |
| 135 | +// console.log(typeof score1) |
| 136 | + |
| 137 | +// let character = { |
| 138 | +// name: "Marlin", |
| 139 | +// age: "999", |
| 140 | +// gender: "male", |
| 141 | +// hobby: "Read Book", |
| 142 | +// alive: true, |
| 143 | +// spell: ["Thunder bolt ⚡", "Fire ball 🔥", "Heal ➕"], |
| 144 | +// ThunderSpell: function () { |
| 145 | +// alert(character.name + " Cast " + character.spell[0] + "Spell!"); |
| 146 | +// return true; |
| 147 | +// }, |
| 148 | +// }; |
| 149 | + |
| 150 | +// console.log(character.ThunderSpell()); |
| 151 | + |
| 152 | +// let student = { |
| 153 | +// name: "amir", |
| 154 | +// age: "18", |
| 155 | +// skills: ["HTML", "CSS", "JS"], |
| 156 | +// introduction: function () { |
| 157 | +// alert("Hello I'm " + this.name); |
| 158 | +// return true; |
| 159 | +// }, |
| 160 | +// }; |
| 161 | + |
| 162 | +// console.log(student.introduction()); |
| 163 | + |
| 164 | +function add(a, b) { |
| 165 | + return a + b; |
| 166 | +} |
| 167 | + |
| 168 | +let addTwo = add.bind(null, 2) |
| 169 | +console.log(addTwo(5)) |
| 170 | + |
| 171 | +let addThree = add.bind(null,9) |
| 172 | +console.log(addThree(1)) |
| 173 | + |
| 174 | +const add = (a,b) => a + b; |
| 175 | + |
| 176 | +let add2 = a => a |
| 177 | +add(a,b) |
| 178 | + |
| 179 | +const multiply = (a,b,c) => a * b * c |
| 180 | +const multiplyTwo = multiply.bind(null,2) |
| 181 | +console.log(multiplyTwo(4,8)) |
| 182 | + |
0 commit comments