How to concatenate a string with a variable in JavaScript

2 Answers

0 votes
const v = 'javascript';
const n = 45876;
 
const s = `lang: ${v} : ${n}`;
 
console.log(s); 
    
    
    
    
/*
run:
    
"lang: javascript : 45876"
    
*/

 



answered Apr 22, 2022 by avibootz
edited Apr 22, 2022 by avibootz
0 votes
const v = 'javascript';
const n = 45876;

const s = "lang: " + v + " " + n;

console.log(s); 
   
   
   
   
/*
run:
   
"lang: javascript 45876"
   
*/

 



answered Apr 22, 2022 by avibootz

Related questions

2 answers 184 views
2 answers 172 views
1 answer 104 views
1 answer 128 views
2 answers 249 views
...