Whats my codes problem? (JavaScript)

javascript

#1

Hey so I was trying to make a test 'script game' thing. But It's not working. Did I mess up completely on the code? Please help if you can. I have been messing with it but can't figure out what I did wrong. Here is my code:

if confirm("Are you ready to start?") {
console.log("k good");
}
else {
console.log("Shut up and click ok")
}

prompt("Enter your name: ")
console.read(function(name){
console.log('K. Your name is now ' + name + '.');
});
console.log("And now random stuff");
console.log("Please ignore this")
console.log("Hi")

var userAnswer = prompt("Type in yes");

if(userAnswer = "yes") {
console.log("Yay you know how to type");
}
else(userAnswer = "no")
console.log("learn how to type yes")

var feedback = prompt("say a number 1-7")
if (userAnswer < 8)
console.log("Good you know how to count")
else (userAnswer > 8)
console.log("Learn how to count")

if confirm("K its over, click OK now") {
console.log("K bye");
}
else {
console.log("Too bad its over")
}


#2

if requires brackets, you have:

if condition {

}

this should be:

if (condition){

}

you have this several times. (there are sites which give more debug info, makes it easier to spot such mistakes)
using a single equal sign:

if(userAnswer = "yes")

inside a if clause is a bad idea, try using a double equal sign for comparison.

else can't have a condition, since it is everything else, you have:

else (userAnswer > 8)

should be:

else

(like i said, else can't have a condition)


#3

ohhhh! Thanks for the help!