A short game from the Brad Traversy Javascript course. We will be coding the javascript ourselves.
https://teniola-thedev.github.io/Number-Guesser/
- I prefer using ordered lists to unordered lists
- git commit -a -m ""
- I could not see the values of my span after setting what should be there in javascript
let min = 1,
max = 10,
const maxNum = document.querySelector('.max-num');
maxNum.textContent = max;
//NOT
maxNum.value = max;
- Cannot set property 'color' of Undefined in JS
I WAS DOING
message.textContent.style.color = color;
INSTEAD OF
message.style.color = color;
- To define a color as a parameter, add it in quotes
function setMessage(error, color) {
message.style.color = color;
message.textContent = error;
}
setMessage('Kindly input a number between 1 and 10', 'red');
- forgot how to declare ternary operator
function gameOver(won, msg) {
let color;
won === true ? (color = 'green') : (color = 'red');
guessInput.disabled = won;
guessInput.style.borderColor = color;
message.style.color = color;
setMessage(msg, color);
}
- Ran into this error
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener'
SOLUTION
I did not target the DOM element correctly.
- Be able to hide the stuff and only show the input button.
Hoisting.