if ("hello"=5){
console.log("I finished my first course!");
}
else;
{
console.log("HI");
}
it says:ReferenceError: Invalid left-hand side in assignment
console.log("I finished my first course!");
}
else;
{
console.log("HI");
}
it says:ReferenceError: Invalid left-hand side in assignment
15
here is what it resulted to=
// Check if the user is ready to play!
confirm ("Ready to play");
var age = prompt("What is your age?");
if (age>7) {
console.log("Ready to play");
}
else{
console.log("sorry to young to play");
}
if (age>7){
console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
}
else{
console.log("goodbye");
}
console.log("Batman glares at you.");
var userAnswer=prompt("Are you feeling lucky, punk");
if (userAnswer="yes"){
console.log("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!");
}
else{
console.log("You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.")}
var feedback=prompt("Rate my Game 1-10");
if (feedback>8){
console.log("This is just the beginning of my game empire. Stay tuned for more!");
}
else{
console.log("I slaved away at this game and you gave me that score?! The nerve! Just you wait!");
}
just push F12 on chrome and enter it into the console.
// Check if the user is ready to play!
confirm ("Ready to play");
var age = prompt("What is your age?");
if (age>7) {
console.log("Ready to play");
}
else{
console.log("sorry to young to play");
}
if (age>7){
console.log("Snow White and Batman were hanging out at the bus stop, waiting to go to the shops. There was a sale on and both needed some new threads. You've never really liked Batman. You walk up to him.");
}
else{
console.log("goodbye");
}
console.log("Batman glares at you.");
var userAnswer=prompt("Are you feeling lucky, punk");
if (userAnswer="yes"){
console.log("Batman hits you very hard. It's Batman and you're you! Of course Batman wins!");
}
else{
console.log("You did not say yes to feeling lucky. Good choice! You are a winner in the game of not getting beaten up by Batman.")}
var feedback=prompt("Rate my Game 1-10");
if (feedback>8){
console.log("This is just the beginning of my game empire. Stay tuned for more!");
}
else{
console.log("I slaved away at this game and you gave me that score?! The nerve! Just you wait!");
}
just push F12 on chrome and enter it into the console.
CodeAcademy
Hm.. wasn't aware of the console.log function however I was under the assuption he had an increment somewhere and thought to type out a variable you needed quotations lol.
?
Thx everyone... it works now
You added a semicolon after the else statement. You should never do that.
Also, don't ask here. Google for a Java developing forum, or just post on Bukkit forums (if you're making a Bukkit plugin).
Also, don't ask here. Google for a Java developing forum, or just post on Bukkit forums (if you're making a Bukkit plugin).
You basicaly stated the STRING 'hello' is the INTEGER '5' then log the "I finished my first course".
You need to correct it so that both variable are either a string or integer, and then put 2 '=' like so '==' In order to say equal to rather than it is equal. 2 equal signs mean if they are equal where as one states that they are. Here is your correction.
What you need to do is create a new variable named hello which is an integer. Then use the code above.
A run through:
If the variable HELLO is equal to the number 5 (2 = signs) then:
Hope that helps lol I'm no good at explaining things :p
You need to correct it so that both variable are either a string or integer, and then put 2 '=' like so '==' In order to say equal to rather than it is equal. 2 equal signs mean if they are equal where as one states that they are. Here is your correction.
if (hello == 5){
console.log("I finished my first course!");
}
else
{
console.log("HI");
}
What you need to do is create a new variable named hello which is an integer. Then use the code above.
A run through:
if (hello == 5){If the variable HELLO is equal to the number 5 (2 = signs) then:
console.log("I finished my first course!");
}
else
{
console.log("HI");
}Hope that helps lol I'm no good at explaining things :p
That's right, but it's not what he wants to do.
if you want to take input from a player, use
Edit: Guy above me, this is Javascript not Java
var hello = "hello";
if (hello.length == 5)
{
console.log("I finished my first course!");
}
else
{
console.log("Hi");
}
if you want to take input from a player, use
var hello = prompt("Enter a five digit string/Hello);Edit: Guy above me, this is Javascript not Java
No information was given to what he wanted to do or what the language was, I assumed it was Java as it is posted in a minecraft site and what was wrote in the original post is java. There was no Javascript involved. Couldn't really tell without the function being seen within the original post.
console.log is only a function in Javascript. In Java it's System.out.println(). The Java/JS bit was aimed at Dansorz, not you I assumed seeing as he was using a string and checking if it was equal to 5, he meant the length and not a variable called hello, as it would be odd to check if 5 == 5 and print out that it works.
[deleted]
Yay Python!
Do what the person above said, however.. "hello" will never be 5. I guess you wanted that to be an integer variable. Remove the quotes then.
Daniel
Do what the person above said, however.. "hello" will never be 5. I guess you wanted that to be an integer variable. Remove the quotes then.
Daniel
[deleted]
