freeCodeCamp icon indicating copy to clipboard operation
freeCodeCamp copied to clipboard

Challenge fail using jQuery selector with single quotes

Open matthew02 opened this issue 11 years ago • 2 comments

Challenge http://www.freecodecamp.com/challenges/waypoint-bring-your-javascript-slot-machine-to-life has an issue.

The second condition for this challenge:

You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slotTwo and slotThree respectively

The selector in the description:

$($(".slot")[0]).html(slotOne);

The condition passes when you use double quotes in the selector per the description:

$($(".slot")[0]).html(slotOne);
$($(".slot")[1]).html(slotTwo);
$($(".slot")[2]).html(slotThree);

It fails with single quotes:

$($('.slot')[0]).html(slotOne);
$($('.slot')[1]).html(slotTwo);
$($('.slot')[2]).html(slotThree);

Maybe we are trying to conform to the jQuery JavaScript Style Guide? Still, both seem to be valid JavaScript. Indeed, the challenge immediately following this one uses single quotes for the selector in the description and passes with either single or double quotes.

Waypoint: Give your JavaScript Slot Machine some stylish images

$($('.slot')[0]).html('<img src = "' + images[slotOne-1] + '">');

39-fail 39-pass

matthew02 avatar Aug 22 '15 21:08 matthew02

Hey @matthew02 thanks for posting this!

There are a few duplicate issues here but yours looks like it is the most detailed so I'll leave it as the main one.

The fix will have to be similar to the fix that closed #2364.

benschenker avatar Aug 23 '15 05:08 benschenker

Closing this issue as https://github.com/FreeCodeCamp/FreeCodeCamp/pull/3125 is merged.

bugron avatar Sep 10 '15 03:09 bugron