Advance Js - Template Strings


Before

 
let user = "Yahoo Baba";
let marks = 350;
document.write("Hello " + user + " your marks is"+marks);


With Template String

 
let user = "Yahoo Baba";
let marks = 350;
document.write(`Hello  ${user}  your marks is ${marks}`);


Template String with Function

 
let firstName = "Yahoo";
let lastName = "Baba";

function fullname(firstName, lastName){
   return `${firstName} ${lastName}`;
}

let hello = `Hello  ${fullname(firstName, lastName)}  Welcome to 2021.`;

document.write(hello);