Top.Mail.Ru
Ответы

Подскажите пожалуйста, как написать "Khal Drogo's favorite word is "athjahakar"" на языке JavaScript?

Напишите программу, которая выведет на экран:

"Khal Drogo's favorite word is "athjahakar""

Дополнен

Если не удобно, пишите мне в ТГ (@programingalllanguages)

По дате
По рейтингу
Аватар пользователя
Гений

Именно с внешними двойными кавычками?

1
 console.log(`"Khal Drogo's favorite word is "athjahakar""`); 

В современном JS три вида ограничителей строк.

Аватар пользователя
Ученик

❯ test.js (1 test | 1 failed) 15ms
× hello world 13ms
→ alert is not defined

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

FAIL test.js > hello world
ReferenceError: alert is not defined
❯ index.js:1:1
1| alert(`"Khal Drogo's favorite word is "athjahakar""`);
| ^
2|
❯ test.js:7:3

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯


Test Files 1 failed (1)
Tests 1 failed (1)
Start at 11:01:03
Duration 492ms (transform 5ms, setup 0ms, collect 11ms, tests 15ms, environment 0ms, prepare 137ms)

make: *** [Makefile:2: test] Error 1
#<Process::Status: pid 55833 exit 2

Аватар пользователя
Гений

Значит, замени alert на console.log:

1
 console.log(`"Khal Drogo's favorite word is "athjahakar""`); 
Аватар пользователя
Ученик
1
 console.log("Khal Drogo's favorite word is athjahakar") 
Аватар пользователя
Ученик

Нет:

❯ test.js (1 test | 1 failed) 16ms
× hello world 15ms
→ expected 'Khal Drogo\'s favorite word is athjah…' to be '"Khal Drogo\'s favorite word is "athj…' // Object.is equality

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

FAIL test.js > hello world
AssertionError: expected 'Khal Drogo\'s favorite word is athjah…' to be '"Khal Drogo\'s favorite word is "athj…' // Object.is equality

❯ test.js:11:20
9| const firstArg = consoleLogSpy.mock.calls.join('\n');
10|
11| expect(firstArg).toBe("\"Khal Drogo's favorite word is \"athjahakar\…
| ^
12| })
13|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

make: *** [Makefile:2: test] Error 1
#<Process::Status: pid 55645 exit 2>

Аватар пользователя
Ученик

Странно, у меня всё хорошо.



Видео по теме