Jul 19, 2024
///* ... */console.log('Hello World');++--+-*/% (to get the remainder)** (example: a ** b)*a++ <=> a = a + 1a-- <=> a = a - 1a += 4 signifies a = a + 4==!====!==><>=<=&&||!if (condition) {
// Code to be executed if condition is truthy
}
if (condition) {
// Code to be executed if condition is truthy
} else {
// Code to be executed if condition is falsy
}
if (condition1) {
// Code to execute if condition1 is true
} else if (condition2) {
// Code to execute if condition2 is true
} else {
// Code to execute if none of the above conditions are true
}
condition ? expr1 : expr2let result = (age >= 18) ? 'Adult' : 'Not Adult';// Multiple Check
let number = prompt('Enter a number:');
if (number % 3 === 0) {
console.log(number + ' is a multiple of 3');
} else if (number % 5 === 0) {
console.log(number + ' is a multiple of 5');
} else {
console.log(number + ' is not a multiple of 3 or 5');
}
// Grading System
let score = prompt('Enter your score:');
let grade;
if (score >= 90 && score <= 100) {
grade = 'A';
} else if (score >= 70 && score <= 89) {
grade = 'B';
} else if (score >= 60 && score <= 69) {
grade = 'C';
} else if (score >= 50 && score <= 59) {
grade = 'D';
} else if (score >= 0 and score <= 49) {
grade = 'F';
}
console.log('According to your score, your grade is ' + grade);