Why are some parameters in quotation brackets? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why are some parameters in quotation brackets?

function sayHello(name, age) { document.write( name + " is " + age + " years old."); } sayHello("John", 20) //Outputs "John is 20 years old." why is john in "

26th Jan 2017, 6:44 AM
Mask
Mask - avatar
4 Answers
+ 7
Because John is a string.
26th Jan 2017, 6:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 7
It will be hilarious if someone named John came in and go like "Hey, I'm not a string."
26th Jan 2017, 7:30 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
"John" is a string John would be a variable 20 is integer "20" is string :) Hope this helps, even a bit.
26th Jan 2017, 6:54 AM
Jani Sinkkonen
Jani Sinkkonen - avatar
0
Thanks for the help guys :D
26th Jan 2017, 7:30 AM
Mask
Mask - avatar