Having issue with the right syntax for line break in JavaScript code.How to get the line break? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Having issue with the right syntax for line break in JavaScript code.How to get the line break?

var countOfRooms = 15; // Your code here for(i=1;i<=countOfRooms;i++){ if(i==13){ continue; } console.log(i+"\n"); }

13th Feb 2024, 11:14 AM
Sohel Kumar Samantaray
Sohel Kumar Samantaray - avatar
5 Answers
+ 3
Sohel Kumar Samantaray console.log automatically adds newline. why would you have to add the extra '\n'? Maybe I'm not understanding what you want. Can you give an example of the expected result?
13th Feb 2024, 1:40 PM
Bob_Li
Bob_Li - avatar
+ 1
Bob_Li Expected output: 1 2 3 4 5 6 7 8 9 10 11 12 14 15
13th Feb 2024, 4:07 PM
Sohel Kumar Samantaray
Sohel Kumar Samantaray - avatar
+ 1
var countOfRooms = 15; // Your code here for(i=1;i<=countOfRooms;i++){ if(i==13){ continue; } console.log(i); }
13th Feb 2024, 4:14 PM
Bob_Li
Bob_Li - avatar
0
Try to use ' ' not " "
13th Feb 2024, 12:44 PM
D1M3
D1M3 - avatar
0
Bob_Li My output: 1234567891011121414
13th Feb 2024, 4:08 PM
Sohel Kumar Samantaray
Sohel Kumar Samantaray - avatar