Consider this code:
var age = 3;
console.log(\"I\'m \" + age + \" years old!\");
Are there any other ways to insert the value of a variabl
Couldn't find what I was looking for, then found it -
If you're using Node.js, there's a built-in util
package with a format function that works like this:
util.format("Hello my name is %s", "Brent");
> Hello my name is Brent
Coincidentally this is now built into console.log
flavors too in Node.js -
console.log("This really bad error happened: %s", "ReferenceError");
> This really bad error happened: ReferenceError