JavaScript-from-Beginner-to.../Chapter 02/Code Samples/ch2_calculations_conversions.js
2021-12-02 21:21:10 +01:00

44 lines
1.0 KiB
JavaScript
Executable File

// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 * nr2);
// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 + nr2);
// let nrToStr = 6;
// nrToStr = String(nrToStr);
// 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);
// let strToNr2 = "hello";
// strToNr2 = Number(strToNr2);
// console.log(strToNr2, typeof strToNr2);
// let strToBool = "";
// strToBool = Boolean(strToBool);
// console.log(strToBool, typeof strToBool);
// let strToBool2 = "false";
// strToBool2 = Boolean(strToBool2);
// console.log(strToBool2, typeof strToBool2);
// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 + Number(nr2));