Обязательно ли одна команда должна находиться на одной строке?
Можно ли сделать валидным в JavaScript подобное:
var string = 'It was 94 fahrenheit outside, so :insertx: went for a walk.
When they got to :inserty:, they stared in horror for a few moments, then :insertz:.
Bob saw the whole thing, but was not surprised — :insertx: weighs 300 pounds, and it was a hot day.';
Ответы (1 шт):
Автор решения: Grundy
→ Ссылка
Можно воспользоваться template literal, которые допускают внутри себя переносы строк:
var string = `It was 94 fahrenheit outside, so :insertx: went for a walk.
When they got to :inserty:, they stared in horror for a few moments, then :insertz:.
Bob saw the whole thing, but was not surprised — :insertx: weighs 300 pounds, and it was a hot day.`;
Также можно добавить экранирование переносов:
var string = 'It was 94 fahrenheit outside, so :insertx: went for a walk. \
When they got to :inserty:, they stared in horror for a few moments, then :insertz:. \
Bob saw the whole thing, but was not surprised — :insertx: weighs 300 pounds, and it was a hot day.';