Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions format.js
Original file line number Diff line number Diff line change
@@ -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);