Search code examples
javascriptcomparison

lost with comparison expression in javaScript


I'm doing a challenge and I've been given this to resolve but I can't find the error.

Declare a variable named speed and set it equal to 90.

Then declare a second variable named busExplodes and assign it the result of a comparison expression that checks if speed is lesser than 80.

Print the result to the console.

var speed = 90;
var busExplodes = 80 < 90;
console.log (busExplodes);

I get this error: >>>>Code is incorrect Your condition should evaluate if speed is lesser than 80.

What am I doing wrong?


Solution

  • You can accomplish this task with the following JavaScript code:

    // Declare a variable named speed and set its value to 90
    let speed = 90;
    
    // Declare a second variable named busExplodes and assign it the result of a comparison expression that checks if speed is less than 80
    let busExplodes = speed < 80;
    
    // Print the result to the console
    console.log(busExplodes);