Search code examples
typescripttslint

How to use single quotes in console.log with multiple variables


If I write

console.log("entered values are "+A+" and "+B);

the tsLint complains that I should use single quotes. I found that if I use single quotes thatn I can't use multiple variables in single console.log i.e. I can't do

console.log('entered values are '+a+' and '+B);

Am I correct that I can't use multiple variables and single quotes if tslint warning about quotes is ON?


Solution

  • You are not correct. I guess you have a type, like changing A for a.

    "entered values are "+A+" and "+B
    

    is equivalent to

    'entered values are '+A+' and '+B`  
    

    is equivalent to

    `entered values are ${A} and ${B}`