let colour: string = "Blue";
// if (condition){
// code inside will run if the condition returns true
// }
if (colour === "Blue"){
console.log("Blue");
}
else if (colour === "Green"){
console.log("Green");
}
else {
console.log("red");
}
// or you could do this
// let var_name = condition;
// if (var_name){
// code inside will run if the condition returns true
// }
let num: number = 10;
let isNumberEven: boolean = num % 2 == 0; // boolean expression
if (isNumberEven){
console.log("Yes");
}
else {
console.log("No");
}
const max = 100;
let counter = 0;
if (counter < max) {
counter++;
}
console.log(counter); // 1
Code language: JavaScript (javascript)