r/code • u/OsamuMidoriya • Mar 14 '24
My Own Code uncaught SyntaxError
were making a lovers game when the girl puts her name and then her boyfriend and gets a number % back . i keep geting a uncaught SyntaxError: Unexpected token '{' on line 7
- prompt('what is your name ');
- prompt("what is your lover's name");
- var loveS = Math.floor(Math.random() * 100)+1;
- prompt('your love score is '+ loveS +'%');
- if(loveS < 50){
- prompt('not looking good');
- }elseif(loveS > 51 && loveS < 75){
- prompt('good but needs work');
- }else(loveS>75){
- prompt('match made in heaven');
- }
would wrapping it in a try block and console.loging the error help
2
Upvotes
View all comments
Show parent comment
2
u/angryrancor Boss Mar 16 '24
What? That's a different error on a different line. Remove the
(loveS>75)There is no reason to put a condition after
else, else catches all conditions not covered by theifandelse if's you've set up before it.Are you reading the lessons before asking us to help you debug this? These are very simple syntax issues.