diff --git a/format.js b/format.js new file mode 100644 index 0000000..747b3b8 --- /dev/null +++ b/format.js @@ -0,0 +1,15 @@ +const name = "Alice"; +const age = 25; +const height = 5.8; + +// Using template literals (template strings) - ES6+ +const formattedString = `My name is ${name}, I am ${age} years old, and my height is ${height.toFixed(2)} feet.`; +console.log(formattedString); + +// Using String.prototype.concat() +const formattedString2 = "My name is ".concat(name, ", I am ", age, " years old, and my height is ", height.toFixed(2), " feet."); +console.log(formattedString2); + +// Using string concatenation (+ operator) +const formattedString3 = "My name is " + name + ", I am " + age + " years old, and my height is " + height.toFixed(2) + " feet."; +console.log(formattedString3);