javascript - string templates not working - js -


i learning how template strings works es2015 somehow output not expected don't see did wrong.

can please give me hand?

function builduser(first, last){     let fullname = '${first} ${last}';      return { first, last, fullname }; }  let b = builduser("talyer", "willams"); console.log(b); 

what object expected object returns

first: talyer last: willams fullname: ${first} ${last} 

why getting ${first} ${last}? shouldn't talyer willams?

you need using backtick not single quote

let fullname = '${first} ${last}'; 

should

let fullname = `${first} ${last}`; 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -