Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // let num = 10
- //increment
- // num = num + 1
- // num += 1
- // num++
- // // decrement
- // num = num - 1
- // num -= 1
- // num--
- // console.log(num++)
- // console.log(num)
- // console.log(++num)
- // console.log(num)
- //falsy values
- //false
- //0
- //undefined
- //NaN
- //''
- //truthy values
- //other than falsy values
- //how to check truthy or falsy values
- // console.log(!!'')
- // console.log(!!NaN)
- // console.log(!!false)
- // console.log(!!18)
- // const age = 18
- // if (age === 18) {
- // console.log('you can vote')
- // } else {
- // console.log("you can't vote")
- // }
- //logical AND(&&)
- // const result = age === 19 && 'you can vote'
- // console.log(result)
- //ternary operator
- // age === 18 ? console.log('you can vote') : console.log('you can\'t vote')
- // const age = 20
- // // console.log(age >= 18 && age)
- // //multiple if else if(use switch)
- // switch (age) {
- // case age >= 18 && age <= 21 && age:
- // console.log('you can vote')
- // break
- // case 15:
- // console.log("you can't vote")
- // break
- // default:
- // console.log('You are of unknown age')
- // }
- //loop (repetition)
- //for,while
- // let arr = ['a', 'b', 'c', 'd']
- // arr[0]
- // arr[1]
- //simple for loop
- // for (let i = 0; i < arr.length; i++) {
- // console.log(i)
- // console.log(arr[i])
- // }
- //for of loop
- // for(let elm of arr){
- // console.log(elm)
- // }
- //while loop
- // let i = 0
- // while (i < arr.length) {
- // console.log(arr[i])
- // i++
- // }
- //break and continue
- // for (let i = 0; i < 10; i++) {
- // if(i === 7){
- // break
- // }
- // console.log(i)
- // let number = i + 1
- // console.log(`we love bangladesh ${number} ${number >= 1 ? 'times' : 'time'}`)
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement