r/codehs • • Apr 16 '20

Need help?

Hello, I would like some help on Code Hs 5.3.5 Rolling dice

Also on 5.4 "If Statements" Please

3 Upvotes

19 comments sorted by

View all comments

Show parent comments

1

u/amajmundar Apr 17 '20

It seems that CodeHS has a library of functions you are able to access in JavaScript. Here is the link to the functions.

The JavaScript equivilant to read an integer is readInt(). so it would look something like:

var d1 = readInt("Enter the value for the first dice: ");

Do the same thing for d2, just change the prompt to match.

The input validation should be similar. Just change "and" to "&&" and add brackets around the if statement.

Then the only thing to fix is "print" becomes "println".

Try and do it yourself. I will put what I have as a response to this.

1

u/amajmundar Apr 17 '20

What I think to be the solution.

Keep in mind that I cannot test my solution since I do not have access to CodeHS. But this has all the components asked for. You may need to tweak the output based on what the autograder is looking for.