📚 › JavaScript: make pages do things
5. Decisions with if and else
इस लेख का अनुवाद अपने आप होगा। अभी अंग्रेज़ी में दिखाया जा रहा है।
An if statement runs code only when its condition is true. else runs when it is false, and else if checks another condition.
if (score >= 50) checks whether the score is 50 or more.
उदाहरण देखें
let age = 20;
if (age >= 18) {
console.log("adult");
} else {
console.log("minor");
}
✍️ अब आपकी बारी
Let score = 72. Print pass if the score is 50 or more, otherwise fail.