1
resposta

This is my suggestion for the application of "console.log".

In my code, I modified the index.html file and app.js in the secret number game

file index.html


<div class="container__texto">
                    <h1></h1>
                    <h2></h2>
</div>

file app.js

alert('Welcome to the secret number game!');


let secretNumber = Math.floor(Math.random() * 10) + 1;

let myNumber = parseInt(prompt('What is the secret number?'));

console.log("Your number is: " + myNumber + " The secret number is: "+ secretNumber);
if (myNumber === secretNumber) {
    console.log('You got it right!');
    HTMLElement = document.querySelector('h1');
    HTMLElement.innerHTML = "You won!";
    HTMLElement = document.querySelector('h2');
    HTMLElement.innerHTML = "The secret number was: " + secretNumber + "\nYou guessed: " + myNumber;
}
else {
    alert('Try again!');
    console.log('The number is wrong!');
    HTMLElement = document.querySelector('h1');
    HTMLElement.innerHTML = "You lose!";
    HTMLElement = document.querySelector('h2');
    HTMLElement.innerHTML = "The secret number was: " + secretNumber;
}
1 resposta

Hello, Gabriel! How are you?

It's great to see you exploring the use of console.log in your code! It really is a powerful tool for debugging and understanding the flow of the program.

If any questions arise, I am at your disposal.

Best regards and happy studying!