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
| const cars = ["toyota","honda","ford"]; | |
| console.log(cars.length); | |
| const motorcycles = ["1","2","3","4","7"]; | |
| console.log(motorcycles.length) | |
| const ages=[12,18,22,15,30]; | |
| const adults = ages.filter((age)=> age>= 18); | |
| console.log(adults) |
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
| const animals = ["cat","dog"]; | |
| animals.push("rabbit"); | |
| console.log(animals); | |
| const colors = ["red","blue","green"]; | |
| colors[1] = "yellow"; | |
| console.log(colors); | |
| const colores = ["brown"]; | |
| colores[1]="dark brown"; | |
| console.log(colores); | |
| const cities = ["newyork","london","paris"]; |
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
| function leaveit(){ | |
| function contiInue(){ | |
| return "you look great!" | |
| } | |
| return contiInue(); | |
| } | |
| console.log(leaveit()) |
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
| function outerfunction(){ | |
| function innerfunction(){ | |
| console.log("inner function executed!"); | |
| } | |
| innerfunction(); | |
| } | |
| console.log(outerfunction()); | |
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
| function greet(name){ | |
| return 'Hello, Ahmad!' | |
| } | |
| console.log(greet("CodePen")); | |
| function greet(){ | |
| console.log("you are good"); | |
| } | |
| function add(a,b){ | |
| console.log(a+b); | |
| } |
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 counter = 0; | |
| while (counter < 5){ | |
| if (counter === 3) | |
| break; | |
| console.log(counter); | |
| counter ++; | |
| } | |
| let counter1 = 1; | |
| while (counter1 < 10){ | |
| if (counter1 === 12) |
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
| for (i = 5; i < 10; i ++){ | |
| console.log(i); | |
| } |
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 day = "Friday"; | |
| switch(day){ | |
| case "Sunday": | |
| console.log("today is sunny"); | |
| break; | |
| case "Tuesday": | |
| console.log("today is rainy"); | |
| break; | |
| case "Friday": | |
| console.log("today is snowy"); |
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 worker = " "; | |
| switch(worker){ | |
| case "a": | |
| console.log("He must stay at home"); | |
| break; | |
| case "b": | |
| console.log("He must work out"); | |
| break; | |
| case "c": | |
| console.log("He is not talented"); |
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
| if (12 > 20){ | |
| console.log("he is old enough"); | |
| }else{ | |
| console.log( "you are false" ); | |
| } |
NewerOlder