Challenge


#1

I have completed the Rock Paper Scissors game in the codecademy lesson. I wan to try to make another basic game using JS. Ideas?


#2

I will also accept any other basic JS challenges.


#3

This may be kinda out of your reach but what about a Tic-Tac-Toe Game…


#4

That is a great idea but how would I go about doing it?


#5

See… the fun things about challenges is figuring it out on your own… When you become a programmer when you grow up, no-one is going to assist you… So you should try to do it then ask. Hope this is usefull…


#6

what about a guessing game?
the user has to guess the number between a defined range

http://www.8bitrocket.com/2014/03/23/applesoft-basic-javascript-emulator-my-first-game-from-1979/


#7

I’ll give the guessing game a shot. Its a good idea.


#8

super, I think it is similar to the rock paper scissors game and you are also going to learn something new.

let us know if you need help :slight_smile:


#9

Already working on it. Thanks!


#10

The guessing game is a good idea. Make it give the user 3 tries, and tell them whether it’s lower, higher, or correct. If they don’t guess it after 3 times they fail.


#11

just 3 times … I think that would be hard to guess :grin:


#12

Im only doing 1-10 now, if i get it I will try up to 100


#13

This is how I will assign the number to guess. Thoughts?

var CN = Math.random();
  if (CN <= 0.10) {
    CN = 1;
  }
  else if (CN <= 0.20) {
    CN = 2;
  }
  else if (CN <= 0.30) {
    CN = 3;
  }
  else if (CN <= 0.40) {
    CN = 4;
  }
  else if (CN <= 0.50) {
    CN = 5;
  }
  else if (CN <= 0.60) {
    CN = 6;
  }
  else if (CN <= 0.70) {
    CN = 7;
  }
  else if (CN <= 0.80) {
    CN = 8;
  }
  else if (CN <= 0.90) {
    CN = 9;
  }
  else  {
    CN = 10;
  }
  

#14

You can save yourself some work there. Think about this: what exactly are you doing to each initial CN to get the final number?


#15

Do you mean like multiplying by 10 and rounding?


#16

Yes, like that. Do you feel that you need to check the value each time? Could you use math to just do what needs to be done to your initial CN = Math.random(); and not worry about all those different values?


#17

This might be a bad question, but what does math random do again?


#18

That is the sort of thing you ask Google. :slight_smile: and you test – try asking for and printing values using Math.random()

If you want the specs, the first paragraph gives you that.


#19

would it be something like
var CN = Math.random();
CN = Math.round(CN * 10);


#20

I’m not trying to avoid directly answering your questions, I’m trying to give you the tools to hunt down these sorts of answers yourself.

If I were working on something and I didn’t know if it was doing what I wanted it to, I would test it by getting it to print out CN after you first assign it a random number and then again after you do the next step to it. Test it a whole bunch of times.