When to use plus (+) and comma (,) inside a console.log in javascript? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

When to use plus (+) and comma (,) inside a console.log in javascript?

Hello, I came to a part in my javascript tutorial wherein I was introduced with a comma (,) for somewhat like a string concatenation. I thought I can only use + when joining strings or variables. Here is the example code. let weather = 'sunny' console.log('The weather today is ' , weather) Result: The weather today is sunny. Using the + sign will produce the same results. I just want to know when to use the right operator. This may have been introduced in the earlier part of the tutorial but I completely missed this out. Thank you for the help.

6th May 2022, 10:52 PM
Kristof Villanueva
Kristof Villanueva - avatar
1 Resposta