Java Getting started with Programming


#1

Okay, I suck at math so.. I guess I suck at this and I need help... Can anyone help me?


#2

If you get rid of your equal signs after your (2+1) which seem unnecessary at first sight as well your error should go away.


#3

Well I take that back slightly. Your code will have another error. You need () around your print statement Error Error Error or else you will get an unexpected string error as well.


#4

Syntax
The if statement specifies a block of code to be executed if a condition is true:

if (condition) {
    block of code to be executed if the condition is true
}

The else statement specifies a block of code to be executed if the condition is false:

if (condition) {
    block of code to be executed if the condition is true
} else { 
    block of code to be executed if the condition is false
}

The else if statement specifies a new condition if the first condition is false:

if (condition1) {
    block of code to be executed if condition1 is true
} else if (condition2) {
    block of code to be executed if the condition1 is false and condition2 is true
} else {
    block of code to be executed if the condition1 is false and condition2 is false
}

To print message to console you need to use console.log():

console.log("Error Error Error");

So, you need review your condition and else statement.


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.