mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nprimo
effc28bfd2
|
5 months ago | |
---|---|---|
.. | ||
README.md | 5 months ago |
README.md
Lines
The new line character '\n'
One other special characters in strings is the \n
(new line), we use it to
represent a new line without having to have a new line in our string.
Also the single and double quote delimited strings can't actually have literal new lines:
let fewlines = "\nHellođź‘Ź\nTheređź‘Ź\n";
// Same string but with literal new lines:
let usingLiteral = `
Hellođź‘Ź
Theređź‘Ź
`;
You can use the literal \n
character to split text on each lines:
let splitted = `
Hellođź‘Ź
Theređź‘Ź
`.split("\n");
console.log(splitted); // ['','Hellođź‘Ź','Theređź‘Ź', '']
// Note that empty lines becomes empty strings !
Instructions
You have been recruited to analyse a bunch of poems, your first task is to count the number of lines.
- Declare a variable
linesCount
of the number of lines from the providedpoem
variable.
However, you must ignore empty lines in the beginning and the end using the trim
string method.