Freecodecamp: Bug in Waypoint: Quoting String with Single Quotes

Created on 13 Jan 2016  路  22Comments  路  Source: freeCodeCamp/freeCodeCamp

Challenge Waypoint: Quoting Strings with Single Quotes has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/8.0.7 Safari/600.7.12.
Please describe how to reproduce this issue, and include links to screenshots if possible.

This challenge requires the user to have 2 single quotes and 4 double quotes, but it also asks to get rid of all of the double quotes inside of the string except the ones required to write a string.

screen shot 2016-01-13 at 08 38 06

My code:

var myStr = "<a href='http://www.example.com' target='_blank'>Link</a>";


Original code:

var myStr ="<a href=\"http://www.example.com\" target=\"_blank\">Link</a>";
discussing

Most helpful comment

@pyoo0225 thanks for posting this issue!
The solution is var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'; . For me instruction is unclear. Only after I saw the second test message (You should have two single quotes ' and four double quotes ") I realized what's the solution tests expect. I'll let this open to discuss how we can clarify this instruction.


Please review the Guidelines for Contributing, thank you!.


All 22 comments

@pyoo0225 thanks for posting this issue!
The solution is var myStr = '<a href="http://www.example.com" target="_blank">Link</a>'; . For me instruction is unclear. Only after I saw the second test message (You should have two single quotes ' and four double quotes ") I realized what's the solution tests expect. I'll let this open to discuss how we can clarify this instruction.


Please review the Guidelines for Contributing, thank you!.


Perhaps:

Change the outer quotes on the provided string from double to single and remove the escaping.

or

Change the containing quotes on the provided string from double to single and remove the escaping.

The other option would be to allow both solutions. Technically they're both valid. It probably wouldn't be too hard to change the tests up.

Oh okay, thank you

w3 spec:

By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa. Authors may also use numeric character references to represent double quotes (") and single quotes ('). For double quotes authors can also use the character entity reference ".

In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.

So technically, this is also valid: '<a href="http://www.example.com" target=_blank>Link</a>'
and vice-versa

@DDaems While that may technically be true, it does not conform to the requirements of the challenge. We are not asking them to "Make a syntactically valid HTML anchor tag", but to "Change the quotes from double to single". Doing anything else completely subverts the purpose of the illustrating example.

@SaintPeter they would still need to make the href attribute conform to the requirements. I was just pointing out, if you want to change the test to comform with the w3c standards. You might aswell try to completely conform with it.

I'm having the same trouble as the others on this thread. I reset the screen and even cleared my browser data but notices that FreeCode Camp's display had only removed my code but had not reset their error findings; therefore, when I keyed my answer, that conformed to the format recommended:
myStr ='Link';

I'm still getting errors stating:

  • Remove all the back slashes
    -You should have two single quotes and 4 double quotes.

As you can see there are no back slashes in my code and it conforms to the requirements. This problem needs to be fixed.

removed solution by mod

Thanks.

thanks.

My problem was that the instruction so far have normally provided a variable (like var myStr;) and then had you modify the code below. I rewrote the line several times, but place it below the provided one. So I ended up with something like - myStr = 'http://www.example.com" . . .

Welcome @CatMiller07 @ShivaGuntuku

removed solution by mod

They have changed this to:

'This string has "double quotes" in it. And "probably" lots of them.'

Thank you for the help

removed solution by mod

After read some comments and tested some possible solutions.

I believe this piece of code works: 'Link'

2 Single Quotes
4 Double Quotes

var myStr = "Link";
I could not make it work please help

(((((((var myStr = "Link"; )))))
any one can help?

@anoora17
Please use the HelpJavaScript chat room for getting challenge related help.

Happy Coding.

This answer was accepted
var myStr = '<a href="http://www.example.com" target="_blank">Link</a>';

thank for help anyone :D

Was this page helpful?
0 / 5 - 0 ratings