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.
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)
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:
Can you get the + button to be disabled on
9 instead of
I don’t think it can be short than 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);
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?
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”
Ah… It a while to finish the project. Just wanted to share my code! If anyone finds any error, please let me know!
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.
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?