why color not execute when I type document.write ( p1.color) but age will be executed | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why color not execute when I type document.write ( p1.color) but age will be executed

https://www.sololearn.com/learn/JavaScript/1152/

27th Jul 2018, 2:38 AM
Tirath Sharma
Tirath Sharma - avatar
4 Answers
+ 9
because you have saved the property name as favColor and you are accessing it as color, try p1.favColor
2nd Aug 2018, 12:51 AM
Morpheus
Morpheus - avatar
+ 6
Can you show your code to us so we can see what is the problem.
27th Jul 2018, 2:42 AM
JTLZ
28th Jul 2018, 6:52 AM
Tirath Sharma
Tirath Sharma - avatar
+ 1
You can either replace p1.color with p1.favColor Or you can change the property favColor to color.
14th Aug 2018, 11:19 PM
Taki BMD
Taki BMD - avatar