0
I need help! =)
I’m pretty new to the programming world and I’m currently taking my first javascript class. I’m struggling on a problem I had for homework this week. I need to convert this pseudocode into JavaScript: start var1 = 10 var2 = 20 wksum = 0 rslt = 0 do while var2 < 30 wksum = var1 + var2 if wksum > 30 var1 = var1 - 2 var2 = var2 + 1 else var1 = var1 - 1 var2 = var2 + 3 end if end while loop rslt = var1 + var2 display rslt end Help please? 😅
8 Réponses
+ 2
That is not hard at all! You have to try and then ask if you have a question.
+ 1
Post it in the code section and link here
0
I’ve tried several times and I keep failing to get an output. I think it’s my syntax. I’ll copy what I’ve done and post it.
0
https://code.sololearn.com/WULDcljdpFg0/?ref=app
0
ahh yes I see my errors now. thank you very much!
0
First of all you have to write js code inside the script tag or in js file without tags and then link to it in html file!
Secondly you have to have a semi colon on the end of a line! When you define a var(example: var a = 10; )
To do operations you should place the variable name as it is and not in string format!
Then your numtwo is wrong spelled so there is an error! After all if you need print a var you shouldn't use a string but it's name as it is!
0
What is more your js code doesn't follow your pseudocode example!