Number Guesser Challenge Project (JavaScript)

I am having a challenge to understand why my code isn’t working. The target number and computer number updates but the winner is never displayed, neither is the next round button working after I click on make a guess. I need help.

Hello,
I had the same issue, thank for your reply, I also solved it by

  • checking the type of the userGuess by using typeOf (which return a string)
  • then I converted the string userGuess in integer with parseInt.
  • Then I was able to use the isInteger function. (could also be done by checking directly the parseInt value)
1 Like

Hi everyone,
I am still new to coding and I got my project to run correctly, however I am having trouble with understanding how to do the extra challenge on #8 where they want you to apply 2 numbers to the getAbsoluteDistance() funstion. I think I started it correctly, but I am unsure how to move forward and apply it to the compareGuesses() function. Can someone help me please?

Here is my code currently:

Hi,

I’m glad you were able to solve the problem but nine of the concepts you mentioned was thought in the classes and I don’t understand any of the concepts you used in solving it. May be seeing your code might be if help but I’m new to JavaScript.

Code: https://github.com/samyadel/number-guesser/blob/master/script.js
Live: https://samyadel.github.io/number-guesser/

Can you get the + button to be disabled on 9 instead of 10?

out_of_range_before_disabling_plus

1 Like

Done: https://samyadel.github.io/number-guesser/

1 Like

I don’t think it can be short than this:

Well, actually…

This:

const compareGuesses = (humanGuess,  computerGuess, targetNumber ) => absoluteGuess(targetNumber, computerGuess) < absoluteGuess(targetNumber, humanGuess) ? false : true

could be shortened to this:

const compareGuesses = (humanGuess, computerGuess, targetNumber) => absoluteGuess(targetNumber, humanGuess) <= absoluteGuess(targetNumber, computerGuess);
1 Like

Hello.

I must be doing something wrong because the same code and structure works if you open it with any browser but it doesn’t work while you are implementing the code in the codecademy terminal.

This is a screenshot of the codecademy terminal.

As you can see even after both human and computer make their guesses the ‘Next Round’ button doen’t work and the check winner message does not appear either.

However, the same code and structure works in any brower. Here you have an screenshot.

Can anybody tell me what is going on and why the code is not working under codecademy terminal?

Thank you

You can (should) skip the parentheses around (winner) on the last row, since it’s only one parameter.

I could, in the input box, enter a negative number.

Hi ppl! Here’s my solution:

I think it’s ok. What do you think?

Maybe you accidentally changed something in the other files?
Did you try resetting the project?

not sure man, but there is a typo in compareGuesses “Maths.abs” :man_shrugging:

Ah… It a while to finish the project. Just wanted to share my code! If anyone finds any error, please let me know! :smiley:

https://rakibuzzaman47.github.io/Codeacademy-Number-Guesser-Challenge-Project-JavaScript/index.html

Hello, in step 6 you specify: “…You should be able to make guesses…”
How can I ask the user to enter a value every time a new round starts? Prompt () and readline () don’t seem to work here. Please see my code snippet below.

Thank you.

My solution:

https://github.com/Sof145/Number-Guesser

Hi all!

Any idea how to do the point 8 of the exercise? Also I´m not sure how to make the alert message to work.

Any suggestions to simplify the code?

Thanks!!!