If-satser
status: alpha
author: krm
created: 2026-06-08
1. 🪧 Right and wrong
let answer = prompt("right or wrong?);
if(answer === "right") {
console.log("Good");
} else {
console.log("Bad");
}
1. 🐾 Test 1
> right
2. 🐾 Test 2
> r
2. 🪧 Do we?
let answer = prompt("Do x?");
console.log(answer);
if(answer === "y") {
console.log("x");
}
console.log("z");
1. 🐾 Test 1
> y
2. 🐾 Test 2
> x
3. 🪧 First A, then B
let A = prompt("Press key A?");
let B = prompt("Press key B?");
if(A === "a" || A === "A") {
if(B === "b" || B === "B") {
console.log("Good!");
}
}
console.log("Stop!");
1. 🐾 Test 1
> A
> b
2. 🐾 Test 2
> b
> a
4. 🪧 A and B or not A and not B?
let A = prompt("Press A?");
let B = prompt("Press B?");
if((A === "y" && B === "y") || A === "n" && B === "n")) {
console.log("Start");
} else {
console.log("Stop");
}
1. 🐾 Test 1
> n
> n
2. 🐾 Test 2
> y
> n