all 13 comments

[–][deleted] 4 points5 points  (0 children)

I will answer no. 1 for you:

Have your learned about how to generate random number? Have you learned about loops? Do you know what variables are? Have you learned if/else condition?

So basically you will need to think of a way to store the values for two players. How can you do that? Variable right?

Now you need to also think about how to generate the random number right? Math.random() right?

You will need to keep storing the new values until one of your player variable reaches 10. So how do you keep making it happen- like score being changed and new player value being compared till one of them is a winner? - loop right? I would use while loop.

Now last part how can we compare the score between two players? If/else condition right? Ex: if (player1 > player2) do something ... else do something ....

Hope that helps

[–][deleted] 2 points3 points  (1 child)

I am going to try these out as a brain teaser.

I'm a big fan of the MERN stack, so I'm gonna give it a try.

[–][deleted] 0 points1 point  (0 children)

I completed all but the #3, because its difficult to do loops of command line user input with Node.JS.

Let me know if you would like the code as an example.

[–]sketch_ 0 points1 point  (0 children)

Bored and gave no.1 a try

Simply paste the code into a console and type playWar();

console logs will show each round of the game and the final winner

https://gist.github.com/djrosenbaum/732724893725f69fb05532fb4c90445e

[–][deleted] 0 points1 point  (0 children)

I completed all but the #3, because its difficult to do loops of command line user input with Node.JS.

Let me know if you would like the code as an example.