JacobJohnson10 (0)

I keep trying to run test for exerciseFour but it fails. It is telling me greaterThanFive is already declared line 51

You are viewing a single comment. View All
Answered by vedprad1 (694) [earned 5 cycles]
View Answer
JacobJohnson10 (0)

function exerciseFour(value){
let greaterThanFive = false;
// In this exercise, you will be given a variable, it will be called: value
// You will also be given a variable named: greaterThanFive
// Using an 'if' statement check to see if the value is greater than 5. If it is, re-assign greaterThanFive the boolean true.
if ( value > 5);
var greaterThanFive = true;
// Please write your answer in the line above.
return greaterThanFive;

vedprad1 (694)

@JacobJohnson10 :
You have a few simple errors.
First of all, you are not supposed to put a semicolon after the if statement.
Second, you should not make a new variable inside the if block, because the variable is already made. Remove the var keyword.
Last but not least, you forgot to close the entire function block with a closing brace.

The final product should like this:

function exerciseFour(value) {
  let greaterThanFive = false;
  if (value > 5) greaterThanFive = true;
  return greaterThanFive;

If this answers your question, please check the checkmark on the left side of this message. Thanks and Good Luck!

PS: I don't how your teacher grades your assignments, but wouldn't it be easier if you just did this:

function exerciseFour(value) {
  return value > 5;
AAnonymity (1)

@vedprad1 : You are right. The short way is much easier.