Created
June 6, 2025 03:14
-
-
Save iam-gopi/31cc03d41045df5c4b0914a120a4ae34 to your computer and use it in GitHub Desktop.
JS operator, condition and loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // let a = "ten"; | |
| // if (a == 10 && a < 100) { | |
| // console.log("yes"); | |
| // } else if (a == "ten") { | |
| // console.log("yes string 10"); | |
| // } else { | |
| // console.log("no"); | |
| // } | |
| // console.log("outside if"); | |
| // for (let index = 0; index < array.length; index++) { | |
| // const element = array[index]; | |
| // } | |
| // +, -, *, / - 5, % - reminder | |
| // ++ =>a++ = a = a + 1 | |
| // -- => decrement | |
| // ** - exponential | |
| // assignment operator | |
| // ------------------ | |
| // =, a+=3 =>a = a + 3, -=, *=, /=, %=, **= | |
| // comparision operator | |
| // --------------------- | |
| // a = 10 | |
| // b = 20 | |
| // a == b | |
| // a === b | |
| // a > b | |
| // b < a | |
| // a >= b | |
| // b <= a | |
| // a != b | |
| // a !== b | |
| // condtional operator | |
| // ------------------- | |
| // && - and | |
| // || - or | |
| // ! - not eg: if (!a){} | |
| // a = 10; | |
| // if (!(a > 10)) { | |
| // console.log("test"); | |
| // } | |
| // terinary oeprator | |
| // ------------------ | |
| // ?: => | |
| // if (a > 10) console.log("tes"); | |
| // else console.log(no); | |
| // a > 10 ? console.log("yes") : console.log("no"); | |
| // for (let index = 0; index < 10; index++) { | |
| // console.log(index); | |
| // } | |
| let index = 0; | |
| while (index < 10) { | |
| console.log(index); | |
| index++; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment