Sometimes, we want to add a variable to console.log with JavaScript.
In this article, we’ll look at how to add a variable to console.log with JavaScript.
How to add a variable to console.log with JavaScript?
To add a variable to console.log with JavaScript, we can pass it in as an argument.
For instance, we write
console.log("story", name, "story");
to log the value of name
as the 2nd entry in the console log between the 2 'story'
strings.
Conclusion
To add a variable to console.log with JavaScript, we can pass it in as an argument.