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? šŸ˜…

13th Mar 2019, 5:10 PM
Mychael Whitney
Mychael Whitney - avatar
8 Answers
+ 2
That is not hard at all! You have to try and then ask if you have a question.
13th Mar 2019, 5:14 PM
Lighton
Lighton - avatar
+ 1
Post it in the code section and link here
13th Mar 2019, 5:18 PM
Lighton
Lighton - avatar
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.
13th Mar 2019, 5:17 PM
Mychael Whitney
Mychael Whitney - avatar
13th Mar 2019, 5:39 PM
Mychael Whitney
Mychael Whitney - avatar
0
https://code.sololearn.com/WULDcljdpFg0/?ref=app
13th Mar 2019, 6:32 PM
Lighton
Lighton - avatar
0
ahh yes I see my errors now. thank you very much!
13th Mar 2019, 6:34 PM
Mychael Whitney
Mychael Whitney - avatar
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!
13th Mar 2019, 6:36 PM
Lighton
Lighton - avatar
0
What is more your js code doesn't follow your pseudocode example!
13th Mar 2019, 6:39 PM
Lighton
Lighton - avatar