lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2.05k stars 45 forks source link

Empty string makes the alignment ( of the source and the output) fail #651

Closed DesBw closed 1 month ago

DesBw commented 1 month ago

To reproduce, put the following scripts. They are from a book titled "JavaScript from begnner to professional"

let nrToStr = 6; //number
nrToStr = String(nrToStr); //string
console.log(nrToStr, typeof nrToStr);

let strToNr = "12";
strToNr = Number(strToNr);
console.log(strToNr, typeof strToNr);

let strToBool = "any string will return true";
strToBool = Boolean(strToBool);
console.log(strToBool, typeof strToBool);

let nullToNr = null;
nullToNr = Number(nullToNr);
console.log("null", nullToNr, typeof nullToNr);

let strToNr = "";
strToNr = Number(strToNr);
console.log("empty string", strToNr, typeof strToNr);

Now, comment out the 17th line (let strToNr = "";), the alignment comes back.

DesBw commented 1 month ago

Looks like any kind of error in the case makes the alignment crewed.