From 098946f551d545c2fd26c27a256d557bc9acad0c Mon Sep 17 00:00:00 2001 From: daviinnchi Date: Tue, 3 Oct 2023 17:34:43 +0200 Subject: [PATCH] Random number now generates only when app starts --- src/app.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app.js b/src/app.js index e193972..306fe57 100644 --- a/src/app.js +++ b/src/app.js @@ -4,6 +4,7 @@ const { terminal } = require('./terminal'); const { generateNumber } = require('./numberGenerator'); const { checkAnswer } = require('./checkAnswer'); +const searchedNumber = generateNumber(); function gameStart() { terminal.question('Enter a number: ', (userInput) => { @@ -14,8 +15,6 @@ function gameStart() { return; } - const searchedNumber = generateNumber(); - if (userInput === searchedNumber) { console.log('You won!', `Searched number was: ${searchedNumber}`); terminal.close();