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 (let i = 1; i<=10; i++) { | |
console.log(i); | |
} | |
// 1 2 3 4 5 6 7 8 9 10 | |
const places = ["New York", "Paris", "Rio"]; | |
for (const place of places) { | |
console.log(`I Love ${place}`); | |
} |
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
when(selectedFruit) { | |
"orange" -> print("Oranges are 59 cents a pound.") | |
"apple" -> print("Apples are 32 cents a pound.") | |
"cherry" -> print("Cherries are one dollar a pound.") | |
"mango", "papaya" -> print("Mangoes and papayas are 3 dollars a pound.") | |
else -> print("Sorry, we are out of $selectedFruit.") | |
} |
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
switch (selectedFruit) { | |
case "orange": | |
console.log("Oranges are 59 cents a pound."); | |
break; | |
case "apple": | |
console.log("Apples are 32 cents a pound."); | |
break; | |
case "cherry": | |
console.log("Cherries are one dollar a pound."); | |
break; |
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
val result = if (number > 0) "Positive number" else "Negative number" |
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 result = number > 0 ? "Positive number" : "Negative number"; |
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
val result = if (number > 0) { | |
"Positive number" | |
} else { | |
"Negative number" | |
} |
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 result; | |
if (number > 0) { | |
result = "Positive number"; | |
} else { | |
result = "Negative number"; | |
} |
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 (number > 0) { | |
print("Positive number") | |
} else { | |
print("Negative number") | |
} |
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 (number > 0) { | |
console.log("Positive number"); | |
} else { | |
console.log("Negative number"); | |
} |
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
val carModels = cars.map { it.model } | |
val oldEnought = users.filter { it.age >= 21 } |