JavaScript Overview | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

JavaScript Overview

Can someone help me with 5.2 practice Escape? How do you get rid of the single quote? console.log('I'm learning JavaScript'); console.log("A quote: "Java is to JavaScript as ham is to hamster." ");

16th Mar 2021, 2:55 AM
Maven
Maven - avatar
6 Answers
+ 7
you need to add a \ before the ‘ in the sentence. Like console.log('I\'m learning JavaScript');
16th Mar 2021, 3:55 AM
Sharique Khan
Sharique Khan - avatar
+ 3
or enclose your string in double quote to avoid escaping single one, and reciprocally: console.log("I'm learning JavaScript"); console.log('A quote: "Java is to JavaScript as ham is to hamster."');
16th Mar 2021, 6:59 AM
visph
visph - avatar
+ 1
console.log('I\'m learning JavaScript'); console.log("A quote: \"Java is to JavaScript as ham is to hamster.\" ");
25th Aug 2021, 8:35 AM
Shakhzodbek Komolov
+ 1
add this character '\' (backslash) like this : console.log('\"Im learning JavaScript\"'); so this means the \ character will escape the quotes✌
24th Feb 2023, 2:15 AM
wwwیvegoadvisorیtech
wwwیvegoadvisorیtech - avatar
0
This is correct Answer. console.log('I\'m learning JavaScript'); console.log("A quote: \"Java is to JavaScript as ham is to hamster.\" ");
2nd Sep 2021, 7:50 PM
Ulaganathan Sajanthan
Ulaganathan Sajanthan - avatar
0
console.log("I'm learning JavaScript"); console.log('A quote: "Java is to JavaScript as ham is to hamster."');
28th Feb 2022, 12:25 PM
Hussein
Hussein - avatar