Help A Beginner With Javascript - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help A Beginner With Javascript (1144 Views)
| Help A Beginner With Javascript by Nobody: 8:37am On Apr 29, 2017 |
I just started learning JavaScript and I'm trying to write a program that tells grade based on your score,everytime I input the code I keep getting "SyntaxError: missing ) after condition This is the code I wrote, gurus in the house should help me out I'm testing it on console.log Var scores="grade" if (scores < 100 AND scores> 75); {Console.log( student got an A); } |
| Re: Help A Beginner With Javascript by Nobody: 8:45am On Apr 29, 2017 |
I am a beginner too, but you can try below rewritten code. Var scores="grade"; if (scores < 100 AND scores> 75) {Console.log( "student got an A" ); } Dayvhid: |
| Re: Help A Beginner With Javascript by ANTONINEUTRON(m): 8:50am On Apr 29, 2017 |
misplaced semi-colon ';' |
| Re: Help A Beginner With Javascript by Ftrcdn(m): 1:37pm On Apr 29, 2017 |
If there is something below a beginner then that's what I am. Well, I think the error should be with your "AND". Trying using a double ampersand like this "&&" and if the problem persists remember the word I highlighted.. You are welcome. |
| Re: Help A Beginner With Javascript by Dekatron(m): 4:33pm On Apr 29, 2017 |
Use & & where you used AND.... |
| Re: Help A Beginner With Javascript by yorex2011: 7:51pm On Apr 29, 2017*. Modified: 7:28am On Apr 30, 2017 |
Dayvhid:Should be If(scores < 100 && scores > 75){ console.log('student got an A') ; } Your code sef.. How are you comparing string and numbers...? |
| Re: Help A Beginner With Javascript by etoluw: 10:38pm On Apr 29, 2017 |
Dayvhid:if grades is a variable, you dont need to quote it i.e var scores = grade; |
| Re: Help A Beginner With Javascript by klefjoxey: 7:54am On Apr 30, 2017 |
Dayvhid:Use if else statement |
| Re: Help A Beginner With Javascript by godOfNairaland: 8:22am On Apr 30, 2017 |
Dayvhid:Let me point out the errors: Var scores="grade" ::: should be Var scores=grade; (since grade is a variable, no need for quotation mark). if (scores < 100 AND scores> 75); ::: should be if (scores <= 100 AND scores>= 75) (since both 75 & 100 are also A, it should be less than or equal to && greater than or equal to. Also note that the semi colon at the end of the statement has been removed. You can't put a semi colon at the closing bracket of an If statement). Full code will be: Var scores=grade; if (scores <= 100 AND scores >= 75){ Console.log('student got an A'); } |
| Re: Help A Beginner With Javascript by Nobody: 11:13am On Apr 30, 2017 |
godOfNairaland:This was really helpful,thanks for your time. |
Which Programming Language Should A Beginner Start With? • Mobile Technology: Lets Build A Mobile App With Javascript • 2 • 3 • 4
Three Ways In Which Technology Is Transforming Accounting • Help! Php If Else Logs Out For Months Of August And September • What Is SIM Hosting?