Categories
JavaScript Answers

How to add a variable to console.log with JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.