File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11import readlineSync from 'readline-sync' ;
2-
3- const playGame = ( questiongame , questionRound ) => {
2+ // приветствие и имя
3+ const greetUser = ( ) => {
44 console . log ( 'Welcome to the Brain Games!' ) ;
55 const name = readlineSync . question ( 'May I have your name? ' ) ;
6- console . log ( `Hello,${ name } !` ) ; // приветствие и имя
6+ console . log ( `Hello,${ name } !` ) ;
7+ return name ;
8+ } ;
9+
10+ const playGame = ( questiongame , questionRound ) => {
11+ const greeting = greetUser ( ) ;
712 console . log ( questiongame ) ; // вывод вопроса игры
813 // цикл игры = 3
914 let i = 1 ;
@@ -16,7 +21,7 @@ const playGame = (questiongame, questionRound) => {
1621 // вывод неправильного ответа
1722 const wrong = ( ) => {
1823 console . log (
19- `'${ answer } ' is wrong answer ;(. Correct answer was '${ correctAnsw } '.\nLet's try again, ${ name } !`
24+ `'${ answer } ' is wrong answer ;(. Correct answer was '${ correctAnsw } '.\nLet's try again, ${ greeting } !`
2025 ) ;
2126 } ;
2227 // проверка
@@ -28,7 +33,7 @@ const playGame = (questiongame, questionRound) => {
2833 i += 1 ;
2934 }
3035
31- console . log ( `Congratulations, ${ name } !` ) ;
36+ console . log ( `Congratulations, ${ greeting } !` ) ;
3237} ;
3338
3439export default playGame ;
You can’t perform that action at this time.
0 commit comments