-1

i am new to coding. I actually just started yesterday. And i have this problem with this code. I am using JavaScript. Here is the code:

("Jon".length * 2 / (2+1) === 2 ) {
{
( if console.log( "The answer makes sense!" ); 
}
else( "Wrong Wrong Wrong" )
}

Thank you.

9
  • what exactly is the problem? Commented Dec 2, 2015 at 20:49
  • What is the problem? Please provide more information Commented Dec 2, 2015 at 20:49
  • Wow, now this a weird piece of "code". Commented Dec 2, 2015 at 20:52
  • jsfiddle.net/3u3cywxo Commented Dec 2, 2015 at 20:54
  • That code does not parse. Please provide with a code without syntax errors and a question. Commented Dec 2, 2015 at 20:55

2 Answers 2

1

The correct format is

if(condition){
    //code to execute
}else{
    //code to execute
}

so you need:

if("Jon".length * 2 / (2+1) === 2 ) {
  console.log( "The answer makes sense!" ); 
}
else{
  console.log( "Wrong Wrong Wrong" ); 
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, im gonna try it
Jonas I suggest you google some beginner javascript tutorials, they will help a lot
0

Maybe you mean something like this:

var answer = "Jon";

if (answer.length * 2 / 3 === 2) {
  console.log("The answer makes sense!");
} else {
  console.log("Wrong Wrong Wrong");
}

At least this executes without errors, and I put your string in a variable or else your code would almost make no sense even if it works. Now you can assign any string to the value of "answer" and check the length.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.