The escaping a character(aka using the backslash so you can type in the single-quote') is appearing in my output?


#1


https://www.codecademy.com/courses/learn-javascript/lessons/arrays/exercises/push?action=lesson_resume


It behaved incorrectly as the backslash that is used to escape the character is seen in the output, so instead of the output being:
'RELEASE OF DOUBT PLEASE IT'S E A T I N G M E O U T'

it becomes:
'RELEASE OF DOUBT PLEASE IT\'S E A T I N G M E O U T'


var bucketList=["Get a job that I actually sincerely enjoy", "Make a programme that I find useful to society", "Learn how to do something that my parents are proud of"];
var listItem= bucketList[3];


bucketList.push("Be a functional adult(kinda)", 'RELEASE OF DOUBT PLEASE IT\'S E A T I N G    M E    O U T ');

console.log(bucketList);
console.log(bucketList.length);


#2

Nice use of the escape character. :wink:

Should be fine, only thing is .push usually only takes one parameter. Try separating it, and keep it uniform in terms of using double quotes or single quotes. Revised:

bucketList.push("Be a functional adult(kinda)");
bucketList.push("RELEASE OF DOUBT PLEASE IT\'S E A T I N G    M E    O U T ");

Let me know how this works out... I don't see any actual issue, but this is a possibility.


#4

Hey thanks man! Appreciate the input, but the output is still the same.

Output:
[RELEASE OF DOUBT PLEASE IT\'S E A T I N G M E O U T ' ]

Yeah, I did change it so there's only one string per parameter of each .push function, but it doesn't seem to help. Thanks, tho. Feel free to leave what you think. Again I really appreciate it! :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.