JavaScript Basic Programming Questions
JavaScript Basic Programming Questions
let a = 5, b = 10;
a = a + b; // 15
b = a - b; // 5
a = a - b; // 10
let num = 7;
if (num % 2 === 0) {
console.log("Even");
} else {
console.log("Odd");
// Output: Odd
console.log(max); // Output: 25
4. Reverse a String
6. Factorial of a Number
let num = 5;
let fact = 1;
let n = 6;
let a = 0, b = 1;
console.log(a);
let temp = a + b;
a = b;
b = temp;
// Output: 0 1 1 2 3 5
let sum = 0;
console.log(sum); // Output: 6
let count = 0;
if ("aeiou".includes(char)) {
count++;
console.log(count); // Output: 3
if (num % i === 0) {
isPrime = false;
break;