i want to write this sentence in 3 lines but on scrimba this does not work but on Repl.lt ( https://repl.it/repls/WickedBaggyRegression ) it works, why?
var myStr = 'FirstLine\n\\SecondLine\\\rThirdLine';
console.log(myStr);
It is probably due to how scrimba.com site does interpret and displays your log in its own custom console.
(it probably wrap the text console.log
receives in a single line.)
Try by replacing console.log
by alert
and you will see escape sequences are "preserved" in the alert popup displayed in the simulated browser, which means, they are correct in a JavaScript way :
I also found a course that explain this: https://scrimba.com/p/p4Mrt9/c4vJdha
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.