Ask coding questions

← Back to all posts
TypeError: Cannot read property 'length' of undefined
laksh5 (85)

This is not working, and I do not know why. Please help!

Answered by JustARatherRidi (191) [earned 5 cycles]
View Answer
JustARatherRidi (191)

The problem is at line 88. It looks like you want 2 elements in your story array, but at line 87 you close the array and open it again in the next line.

To put both your strings in the same array, remove the ] in line 87 and replace the [ with a comma in line 88. Your array should now look like this

var story =
	    ["One day, " +
		realPerfectName +
		" was walking down the street, and he/she came to a strange sight. There was chemicals oozing from their home. Curious, he/she touched the chemical and sudddenly, their body began to change. He/she started to have a headache, and he/she became " +
		perfectName +
		"!!!. " +
		perfectName +
		" was not sure about his/her powers, but in the end, he/she used it for " +
		sider + ".", // Notice the comma and the removed brackets
		"One day, " +
		realPerfectName +
		" was walking down the street, and he/she went to work as usual. He/she was experimenting with uranium, until he/she dropped it on his pet hamster. Hastily, he/she cleaned it off of him. At home, his/her hamster bit him/her, and he/she started to feel a bit strange. Woozy, he/she fell on the bed. In the morning, he/she was " +
		perfectName +
		"!!!. "]

Here's a working repl