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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *