Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Javascript string format

let name = "John";
let age = 30;
let food = "pizza";

// String formating using backticks
let sentence = `${name} is ${age} years old and likes ${food}`;

console.log(sentence);
// John is 30 years old and likes pizza

// String formating using plus operator
let sentence = name + ' is ' + age + ' years old and likes ' + food;

console.log(sentence); // John is 30 years old and likes pizza
Source by www.tutorialstonight.com #
 
PREVIOUS NEXT
Tagged: #Javascript #string #format
ADD COMMENT
Topic
Name
8+4 =