Why not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why not working?

function worker(name, age, paycheck, position) { this.name = name; this.age = age; this.paycheck = paycheck; this.position = position; } var p1 = new worker("Alex Ivanov", 25, 1000000, "trader"); var p2 = new worker("Serge Sidorov", 32, 500000, "consultant"); document.write(p1.name+" "); /*Alex Ivanov*/ document.write(p2.name.paycheck); /*undefined*/

4th May 2018, 8:07 AM
Arthur P
Arthur P - avatar
4 Answers
+ 4
the second should be:: document.write(p2.paycheck) not:: document.write(p2.name.paycheck)
4th May 2018, 8:17 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 2
Max Rubs, to make the second string "Serge Sidorov 500000" do: document.write(p2.name + " " + p2.paycheck);
4th May 2018, 9:05 AM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
thanks, but is it possible to make second string "Serge Sidorov 500000" ?
4th May 2018, 8:38 AM
Arthur P
Arthur P - avatar
+ 1
Thanks Bro!
4th May 2018, 10:01 AM
Arthur P
Arthur P - avatar