From d91f26ff841d05a8dc0bee4d022ce1615e9fdc42 Mon Sep 17 00:00:00 2001 From: Raihanul Islam Rakin <102819630+rakin777@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:35:21 +0600 Subject: [PATCH 1/2] Create format.js --- format.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 format.js diff --git a/format.js b/format.js new file mode 100644 index 0000000..b839528 --- /dev/null +++ b/format.js @@ -0,0 +1,15 @@ +const name = "Alice"; +const age = 30; +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); From 550c81d08e2c184df26bcf43fe99903cfb3f12a3 Mon Sep 17 00:00:00 2001 From: Raihanul Islam Rakin <102819630+rakin777@users.noreply.github.com> Date: Wed, 16 Aug 2023 00:37:23 +0600 Subject: [PATCH 2/2] Update format.js --- format.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/format.js b/format.js index b839528..747b3b8 100644 --- a/format.js +++ b/format.js @@ -1,5 +1,5 @@ const name = "Alice"; -const age = 30; +const age = 25; const height = 5.8; // Using template literals (template strings) - ES6+