Home HTML Hacks Data Types Hacks DOM Hacks JavaScript Hacks JS Debugging Hacks

Hacks

  • Write a JavaScript program that compares two variables, a and b. Log “a is greater” if a is greater than b, “b is greater” if b is greater than a, and “both are equal” if a and b are equal. Make sure to use if statements and console.log

%%js

const a = 2;
const b = 4;

if (a > b) {
    console.log("a is greater");

} else if (b > a) {
    console.log("b is greater");

} else {
    console.log("both are equal");
}


<IPython.core.display.Javascript object>