JAVA (plss help)

var myStr;'\"FirstLine\n\t\SecondLine\n\ThirdLine"'; // Change this line

Q-Assign the following three lines of text into the single variable myStr using escape sequences.


First off, when you post a question about a curriculum problem, please use the Get Help -> Ask for Help button - it will post your code and a link to the problem making it easier to help you.

Secondly, in your title you say, “JAVA (plss help)”. Understand that this is JavaScript, not Java, which is a completely different language. They are no more the same language than Spanish and Italian - related, but not the same.

OK, this:

var myStr;’“FirstLine\n\t\SecondLine\n\ThirdLine”’; // Change this line

There are a few problems here.

  1. You never assign the variable. Assigning a variable should be like var x = But you have a semicolon after your variable name, not a =.
  2. You have some extra quote signs in there. You start out with this: ’“. You don’t both in this case, choose one or the other, single or double quotes.
  3. Why in this - \SecondLine - are you trying to escape the “S”? The same with “T” a little later. Remember that in your string, if you want to display a “\” that it too must be escaped.

When I fix those things, your code passes for me.


You seem to be on the right path. However, you may try the below solution. As far as I can understand from your query.


1 Like

Please don’t hand out answers. We’re here to help people understand and fix their code.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

kkk sir now i will keep this in mind

it helped me a lot.

got it

thnk u sir. …

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