fix(challenges): converts delete html test to regex

Also, adds a solution to be tested with the test suite.

ISSUES CLOSED: #251
This commit is contained in:
Josh Alling
2018-08-15 07:53:23 -06:00
committed by Kristofer Koishigawa
parent 2adc516d96
commit d80d98d83c

View File

@ -23,10 +23,8 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your <code>h1</code> element should have the text \"Hello World\".",
"Your <code>h1</code> element should have the text \"Hello World\".", "testString": "assert.isTrue((/hello(\\s)+world/gi).test($('h1').text()), 'Your <code>h1</code> element should have the text \"Hello World\".');"
"testString":
"assert.isTrue((/hello(\\s)+world/gi).test($('h1').text()), 'Your <code>h1</code> element should have the text \"Hello World\".');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -125,25 +123,19 @@
"tests": [ "tests": [
{ {
"text": "Create an <code>h2</code> element.", "text": "Create an <code>h2</code> element.",
"testString": "testString": "assert(($(\"h2\").length > 0), 'Create an <code>h2</code> element.');"
"assert(($(\"h2\").length > 0), 'Create an <code>h2</code> element.');"
}, },
{ {
"text": "Make sure your <code>h2</code> element has a closing tag.", "text": "Make sure your <code>h2</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/h2>/g) && code.match(/<\\/h2>/g).length === code.match(/<h2>/g).length, 'Make sure your <code>h2</code> element has a closing tag.');"
"assert(code.match(/<\\/h2>/g) && code.match(/<\\/h2>/g).length === code.match(/<h2>/g).length, 'Make sure your <code>h2</code> element has a closing tag.');"
}, },
{ {
"text": "text": "Your <code>h2</code> element should have the text \"CatPhotoApp\".",
"Your <code>h2</code> element should have the text \"CatPhotoApp\".", "testString": "assert.isTrue((/cat(\\s)?photo(\\s)?app/gi).test($(\"h2\").text()), 'Your <code>h2</code> element should have the text \"CatPhotoApp\".');"
"testString":
"assert.isTrue((/cat(\\s)?photo(\\s)?app/gi).test($(\"h2\").text()), 'Your <code>h2</code> element should have the text \"CatPhotoApp\".');"
}, },
{ {
"text": "text": "Your <code>h1</code> element should have the text \"Hello World\".",
"Your <code>h1</code> element should have the text \"Hello World\".", "testString": "assert.isTrue((/hello(\\s)+world/gi).test($(\"h1\").text()), 'Your <code>h1</code> element should have the text \"Hello World\".');"
"testString":
"assert.isTrue((/hello(\\s)+world/gi).test($(\"h1\").text()), 'Your <code>h1</code> element should have the text \"Hello World\".');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -216,19 +208,15 @@
"tests": [ "tests": [
{ {
"text": "Create a <code>p</code> element.", "text": "Create a <code>p</code> element.",
"testString": "testString": "assert(($(\"p\").length > 0), 'Create a <code>p</code> element.');"
"assert(($(\"p\").length > 0), 'Create a <code>p</code> element.');"
}, },
{ {
"text": "text": "Your <code>p</code> element should have the text \"Hello Paragraph\".",
"Your <code>p</code> element should have the text \"Hello Paragraph\".", "testString": "assert.isTrue((/hello(\\s)+paragraph/gi).test($(\"p\").text()), 'Your <code>p</code> element should have the text \"Hello Paragraph\".');"
"testString":
"assert.isTrue((/hello(\\s)+paragraph/gi).test($(\"p\").text()), 'Your <code>p</code> element should have the text \"Hello Paragraph\".');"
}, },
{ {
"text": "Make sure your <code>p</code> element has a closing tag.", "text": "Make sure your <code>p</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/p>/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure your <code>p</code> element has a closing tag.');"
"assert(code.match(/<\\/p>/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure your <code>p</code> element has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -296,10 +284,8 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your <code>p</code> element should contain the first few words of the provided <code>kitty ipsum text</code>.",
"Your <code>p</code> element should contain the first few words of the provided <code>kitty ipsum text</code>.", "testString": "assert.isTrue((/Kitty(\\s)+ipsum/gi).test($(\"p\").text()), 'Your <code>p</code> element should contain the first few words of the provided <code>kitty ipsum text</code>.');"
"testString":
"assert.isTrue((/Kitty(\\s)+ipsum/gi).test($(\"p\").text()), 'Your <code>p</code> element should contain the first few words of the provided <code>kitty ipsum text</code>.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -373,28 +359,20 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Make your <code>h1</code> element visible on your page by uncommenting it.",
"Make your <code>h1</code> element visible on your page by uncommenting it.", "testString": "assert($(\"h1\").length > 0, 'Make your <code>h1</code> element visible on your page by uncommenting it.');"
"testString":
"assert($(\"h1\").length > 0, 'Make your <code>h1</code> element visible on your page by uncommenting it.');"
}, },
{ {
"text": "text": "Make your <code>h2</code> element visible on your page by uncommenting it.",
"Make your <code>h2</code> element visible on your page by uncommenting it.", "testString": "assert($(\"h2\").length > 0, 'Make your <code>h2</code> element visible on your page by uncommenting it.');"
"testString":
"assert($(\"h2\").length > 0, 'Make your <code>h2</code> element visible on your page by uncommenting it.');"
}, },
{ {
"text": "text": "Make your <code>p</code> element visible on your page by uncommenting it.",
"Make your <code>p</code> element visible on your page by uncommenting it.", "testString": "assert($(\"p\").length > 0, 'Make your <code>p</code> element visible on your page by uncommenting it.');"
"testString":
"assert($(\"p\").length > 0, 'Make your <code>p</code> element visible on your page by uncommenting it.');"
}, },
{ {
"text": "text": "Be sure to delete all trailing comment tags&#44; i.e. <code>--&#62;</code>.",
"Be sure to delete all trailing comment tags&#44; i.e. <code>--&#62;</code>.", "testString": "assert(!/[^fc]-->/gi.test(code.replace(/ *<!--[^fc]*\\n/g,'')), 'Be sure to delete all trailing comment tags&#44; i.e. <code>--&#62;</code>.');"
"testString":
"assert(!/[^fc]-->/gi.test(code.replace(/ *<!--[^fc]*\\n/g,'')), 'Be sure to delete all trailing comment tags&#44; i.e. <code>--&#62;</code>.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -469,34 +447,24 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Comment out your <code>h1</code> element so that it is not visible on your page.",
"Comment out your <code>h1</code> element so that it is not visible on your page.", "testString": "assert(($(\"h1\").length === 0), 'Comment out your <code>h1</code> element so that it is not visible on your page.');"
"testString":
"assert(($(\"h1\").length === 0), 'Comment out your <code>h1</code> element so that it is not visible on your page.');"
}, },
{ {
"text": "text": "Leave your <code>h2</code> element uncommented so that it is visible on your page.",
"Leave your <code>h2</code> element uncommented so that it is visible on your page.", "testString": "assert(($(\"h2\").length > 0), 'Leave your <code>h2</code> element uncommented so that it is visible on your page.');"
"testString":
"assert(($(\"h2\").length > 0), 'Leave your <code>h2</code> element uncommented so that it is visible on your page.');"
}, },
{ {
"text": "text": "Comment out your <code>p</code> element so that it is not visible on your page.",
"Comment out your <code>p</code> element so that it is not visible on your page.", "testString": "assert(($(\"p\").length === 0), 'Comment out your <code>p</code> element so that it is not visible on your page.');"
"testString":
"assert(($(\"p\").length === 0), 'Comment out your <code>p</code> element so that it is not visible on your page.');"
}, },
{ {
"text": "text": "Be sure to close each of your comments with <code>--&#62;</code>.",
"Be sure to close each of your comments with <code>--&#62;</code>.", "testString": "assert(code.match(/[^fc]-->/g).length > 1, 'Be sure to close each of your comments with <code>--&#62;</code>.');"
"testString":
"assert(code.match(/[^fc]-->/g).length > 1, 'Be sure to close each of your comments with <code>--&#62;</code>.');"
}, },
{ {
"text": "text": "Do not change the order of the <code>h1</code> <code>h2</code> or <code>p</code> in the code.",
"Do not change the order of the <code>h1</code> <code>h2</code> or <code>p</code> in the code.", "testString": "assert((code.match(/<([a-z0-9]){1,2}>/g)[0]===\"<h1>\" && code.match(/<([a-z0-9]){1,2}>/g)[1]===\"<h2>\" && code.match(/<([a-z0-9]){1,2}>/g)[2]===\"<p>\") , 'Do not change the order of the <code>h1</code> <code>h2</code> or <code>p</code> in the code.');"
"testString":
"assert((code.match(/<([a-z0-9]){1,2}>/g)[0]===\"<h1>\" && code.match(/<([a-z0-9]){1,2}>/g)[1]===\"<h2>\" && code.match(/<([a-z0-9]){1,2}>/g)[2]===\"<p>\") , 'Do not change the order of the <code>h1</code> <code>h2</code> or <code>p</code> in the code.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -568,20 +536,20 @@
"tests": [ "tests": [
{ {
"text": "Delete your <code>h1</code> element.", "text": "Delete your <code>h1</code> element.",
"testString": "testString": "assert(!code.match(/<h1>/gi) && !code.match(/<\\/h1>/gi), 'Delete your <code>h1</code> element.');"
"assert(($(\"h1\").length == 0), 'Delete your <code>h1</code> element.');"
}, },
{ {
"text": "Leave your <code>h2</code> element on the page.", "text": "Leave your <code>h2</code> element on the page.",
"testString": "testString": "assert(code.match(/<h2>[\\w\\W]*<\\/h2>/gi), 'Leave your <code>h2</code> element on the page.');"
"assert(($(\"h2\").length > 0), 'Leave your <code>h2</code> element on the page.');"
}, },
{ {
"text": "Leave your <code>p</code> element on the page.", "text": "Leave your <code>p</code> element on the page.",
"testString": "testString": "assert(code.match(/<p>[\\w\\W]*<\\/p>/gi), 'Leave your <code>p</code> element on the page.');"
"assert(($(\"p\").length > 0), 'Leave your <code>p</code> element on the page.');"
} }
], ],
"solutions": [
"var code = \"<h2>CatPhotoApp</h2><p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>\""
],
"challengeType": 0, "challengeType": 0,
"translations": { "translations": {
"de": { "de": {
@ -652,43 +620,31 @@
"tests": [ "tests": [
{ {
"text": "You need 2 <code>p</code> elements with Kitty Ipsum text.", "text": "You need 2 <code>p</code> elements with Kitty Ipsum text.",
"testString": "testString": "assert($(\"p\").length > 1, 'You need 2 <code>p</code> elements with Kitty Ipsum text.');"
"assert($(\"p\").length > 1, 'You need 2 <code>p</code> elements with Kitty Ipsum text.');"
}, },
{ {
"text": "text": "Make sure each of your <code>p</code> elements has a closing tag.",
"Make sure each of your <code>p</code> elements has a closing tag.", "testString": "assert(code.match(/<\\/p>/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure each of your <code>p</code> elements has a closing tag.');"
"testString":
"assert(code.match(/<\\/p>/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure each of your <code>p</code> elements has a closing tag.');"
}, },
{ {
"text": "text": "Your <code>p</code> element should contain the first few words of the provided additional <code>kitty ipsum text</code>.",
"Your <code>p</code> element should contain the first few words of the provided additional <code>kitty ipsum text</code>.", "testString": "assert.isTrue((/Purr\\s+jump\\s+eat/gi).test($(\"p\").text()), 'Your <code>p</code> element should contain the first few words of the provided additional <code>kitty ipsum text</code>.');"
"testString":
"assert.isTrue((/Purr\\s+jump\\s+eat/gi).test($(\"p\").text()), 'Your <code>p</code> element should contain the first few words of the provided additional <code>kitty ipsum text</code>.');"
}, },
{ {
"text": "Your code should have one <code>main</code> element.", "text": "Your code should have one <code>main</code> element.",
"testString": "testString": "assert($('main').length === 1, 'Your code should have one <code>main</code> element.');"
"assert($('main').length === 1, 'Your code should have one <code>main</code> element.');"
}, },
{ {
"text": "text": "The <code>main</code> element should have two paragraph elements as children.",
"The <code>main</code> element should have two paragraph elements as children.", "testString": "assert($(\"main\").children(\"p\").length === 2, 'The <code>main</code> element should have two paragraph elements as children.');"
"testString":
"assert($(\"main\").children(\"p\").length === 2, 'The <code>main</code> element should have two paragraph elements as children.');"
}, },
{ {
"text": "text": "The opening <code>main</code> tag should come before the first paragraph tag.",
"The opening <code>main</code> tag should come before the first paragraph tag.", "testString": "assert(code.match(/<main>\\s*?<p>/g), 'The opening <code>main</code> tag should come before the first paragraph tag.');"
"testString":
"assert(code.match(/<main>\\s*?<p>/g), 'The opening <code>main</code> tag should come before the first paragraph tag.');"
}, },
{ {
"text": "text": "The closing <code>main</code> tag should come after the second closing paragraph tag.",
"The closing <code>main</code> tag should come after the second closing paragraph tag.", "testString": "assert(code.match(/<\\/p>\\s*?<\\/main>/g), 'The closing <code>main</code> tag should come after the second closing paragraph tag.');"
"testString":
"assert(code.match(/<\\/p>\\s*?<\\/main>/g), 'The closing <code>main</code> tag should come after the second closing paragraph tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -744,20 +700,15 @@
"tests": [ "tests": [
{ {
"text": "Your page should have an image element.", "text": "Your page should have an image element.",
"testString": "testString": "assert($(\"img\").length > 0, 'Your page should have an image element.');"
"assert($(\"img\").length > 0, 'Your page should have an image element.');"
}, },
{ {
"text": "text": "Your image should have a <code>src</code> attribute that points to the kitten image.",
"Your image should have a <code>src</code> attribute that points to the kitten image.", "testString": "assert(new RegExp(\"\\/\\/bit.ly\\/fcc-relaxing-cat|\\/\\/s3.amazonaws.com\\/freecodecamp\\/relaxing-cat.jpg\", \"gi\").test($(\"img\").attr(\"src\")), 'Your image should have a <code>src</code> attribute that points to the kitten image.');"
"testString":
"assert(new RegExp(\"\\/\\/bit.ly\\/fcc-relaxing-cat|\\/\\/s3.amazonaws.com\\/freecodecamp\\/relaxing-cat.jpg\", \"gi\").test($(\"img\").attr(\"src\")), 'Your image should have a <code>src</code> attribute that points to the kitten image.');"
}, },
{ {
"text": "text": "Your image element <strong>must</strong> have an <code>alt</code> attribute.",
"Your image element <strong>must</strong> have an <code>alt</code> attribute.", "testString": "assert(code.match(/alt\\s*?=\\s*?(\\\"|\\').*(\\\"|\\')/), 'Your image element <strong>must</strong> have an <code>alt</code> attribute.');"
"testString":
"assert(code.match(/alt\\s*?=\\s*?(\\\"|\\').*(\\\"|\\')/), 'Your image element <strong>must</strong> have an <code>alt</code> attribute.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -817,8 +768,7 @@
] ]
} }
}, },
"guideUrl": "guideUrl": "https://guide.freecodecamp.org/certificates/add-images-to-your-website",
"https://guide.freecodecamp.org/certificates/add-images-to-your-website",
"files": { "files": {
"indexhtml": { "indexhtml": {
"key": "indexhtml", "key": "indexhtml",
@ -851,21 +801,16 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your <code>a</code> element should have the <code>anchor text</code> of \"cat photos\".",
"Your <code>a</code> element should have the <code>anchor text</code> of \"cat photos\".", "testString": "assert((/cat photos/gi).test($(\"a\").text()), 'Your <code>a</code> element should have the <code>anchor text</code> of \"cat photos\".');"
"testString":
"assert((/cat photos/gi).test($(\"a\").text()), 'Your <code>a</code> element should have the <code>anchor text</code> of \"cat photos\".');"
}, },
{ {
"text": "text": "You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code>",
"You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code>", "testString": "assert(/http:\\/\\/(www\\.)?freecatphotoapp\\.com/gi.test($(\"a\").attr(\"href\")), 'You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code>');"
"testString":
"assert(/http:\\/\\/(www\\.)?freecatphotoapp\\.com/gi.test($(\"a\").attr(\"href\")), 'You need an <code>a</code> element that links to <code>http&#58;//freecatphotoapp<wbr>.com</code>');"
}, },
{ {
"text": "Make sure your <code>a</code> element has a closing tag.", "text": "Make sure your <code>a</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/a>/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure your <code>a</code> element has a closing tag.');"
"assert(code.match(/<\\/a>/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure your <code>a</code> element has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -958,44 +903,33 @@
"tests": [ "tests": [
{ {
"text": "There should be only one anchor tag on your page.", "text": "There should be only one anchor tag on your page.",
"testString": "testString": "assert($('a').length == 1, 'There should be only one anchor tag on your page.');"
"assert($('a').length == 1, 'There should be only one anchor tag on your page.');"
}, },
{ {
"text": "text": "There should be only one <code>footer</code> tag on your page.",
"There should be only one <code>footer</code> tag on your page.", "testString": "assert($('footer').length == 1, 'There should be only one <code>footer</code> tag on your page.');"
"testString":
"assert($('footer').length == 1, 'There should be only one <code>footer</code> tag on your page.');"
}, },
{ {
"text": "text": "The <code>a</code> tag should have an <code>href</code> attribute set to \"#footer\".",
"The <code>a</code> tag should have an <code>href</code> attribute set to \"#footer\".", "testString": "assert($('a').eq(0).attr('href') == \"#footer\", 'The <code>a</code> tag should have an <code>href</code> attribute set to \"#footer\".');"
"testString":
"assert($('a').eq(0).attr('href') == \"#footer\", 'The <code>a</code> tag should have an <code>href</code> attribute set to \"#footer\".');"
}, },
{ {
"text": "text": "The <code>a</code> tag should not have a <code>target</code> attribute",
"The <code>a</code> tag should not have a <code>target</code> attribute", "testString": "assert(typeof $('a').eq(0).attr('target') == typeof undefined || $('a').eq(0).attr('target') == true, 'The <code>a</code> tag should not have a <code>target</code> attribute');"
"testString":
"assert(typeof $('a').eq(0).attr('target') == typeof undefined || $('a').eq(0).attr('target') == true, 'The <code>a</code> tag should not have a <code>target</code> attribute');"
}, },
{ {
"text": "The <code>a</code> text should be \"Jump to Bottom\".", "text": "The <code>a</code> text should be \"Jump to Bottom\".",
"testString": "testString": "assert($('a').eq(0).text().match(/Jump to Bottom/gi), 'The <code>a</code> text should be \"Jump to Bottom\".');"
"assert($('a').eq(0).text().match(/Jump to Bottom/gi), 'The <code>a</code> text should be \"Jump to Bottom\".');"
}, },
{ {
"text": "text": "The <code>footer</code> tag should have an <code>id</code> attribute set to \"footer\".",
"The <code>footer</code> tag should have an <code>id</code> attribute set to \"footer\".", "testString": "assert($('footer').eq(0).attr('id') == \"footer\", 'The <code>footer</code> tag should have an <code>id</code> attribute set to \"footer\".');"
"testString":
"assert($('footer').eq(0).attr('id') == \"footer\", 'The <code>footer</code> tag should have an <code>id</code> attribute set to \"footer\".');"
} }
], ],
"challengeType": 0, "challengeType": 0,
"translations": { "translations": {
"pt-br": { "pt-br": {
"title": "title": "Crie links para seções internas de uma página com elementos âncora",
"Crie links para seções internas de uma página com elementos âncora",
"description": [ "description": [
"Além de criar links externos, elementos âncora também podem ser usados para criar links internos, que são links que pulam para diferentes seções dentro de uma mesma página.", "Além de criar links externos, elementos âncora também podem ser usados para criar links internos, que são links que pulam para diferentes seções dentro de uma mesma página.",
"O formato é parecido com um link externo, só que, ao invés de uma URL no atributo <code>href</code>, você usa o símbolo <code>#</code> e uma palavra para descrever a seção para a qual você quer pular.", "O formato é parecido com um link externo, só que, ao invés de uma URL no atributo <code>href</code>, você usa o símbolo <code>#</code> e uma palavra para descrever a seção para a qual você quer pular.",
@ -1056,52 +990,36 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "You need an <code>a</code> element that links to \"http://freecatphotoapp.com\".",
"You need an <code>a</code> element that links to \"http://freecatphotoapp.com\".", "testString": "assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").length > 0 || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").length > 0), 'You need an <code>a</code> element that links to \"http://freecatphotoapp.com\".');"
"testString":
"assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").length > 0 || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").length > 0), 'You need an <code>a</code> element that links to \"http://freecatphotoapp.com\".');"
}, },
{ {
"text": "text": "Your <code>a</code> element should have the anchor text of \"cat photos\"",
"Your <code>a</code> element should have the anchor text of \"cat photos\"", "testString": "assert($(\"a\").text().match(/cat\\sphotos/gi), 'Your <code>a</code> element should have the anchor text of \"cat photos\"');"
"testString":
"assert($(\"a\").text().match(/cat\\sphotos/gi), 'Your <code>a</code> element should have the anchor text of \"cat photos\"');"
}, },
{ {
"text": "text": "Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.",
"Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.", "testString": "assert($(\"p\") && $(\"p\").length > 2, 'Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.');"
"testString":
"assert($(\"p\") && $(\"p\").length > 2, 'Create a new <code>p</code> element around your <code>a</code> element. There should be at least 3 total <code>p</code> tags in your HTML code.');"
}, },
{ {
"text": "text": "Your <code>a</code> element should be nested within your new <code>p</code> element.",
"Your <code>a</code> element should be nested within your new <code>p</code> element.", "testString": "assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").parent().is(\"p\") || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").parent().is(\"p\")), 'Your <code>a</code> element should be nested within your new <code>p</code> element.');"
"testString":
"assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").parent().is(\"p\") || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").parent().is(\"p\")), 'Your <code>a</code> element should be nested within your new <code>p</code> element.');"
}, },
{ {
"text": "text": "Your <code>p</code> element should have the text \"View more \" (with a space after it).",
"Your <code>p</code> element should have the text \"View more \" (with a space after it).", "testString": "assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").parent().text().match(/View\\smore\\s/gi) || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").parent().text().match(/View\\smore\\s/gi)), 'Your <code>p</code> element should have the text \"View more \" (with a space after it).');"
"testString":
"assert(($(\"a[href=\\\"http://freecatphotoapp.com\\\"]\").parent().text().match(/View\\smore\\s/gi) || $(\"a[href=\\\"http://www.freecatphotoapp.com\\\"]\").parent().text().match(/View\\smore\\s/gi)), 'Your <code>p</code> element should have the text \"View more \" (with a space after it).');"
}, },
{ {
"text": "text": "Your <code>a</code> element should <em>not</em> have the text \"View more\".",
"Your <code>a</code> element should <em>not</em> have the text \"View more\".", "testString": "assert(!$(\"a\").text().match(/View\\smore/gi), 'Your <code>a</code> element should <em>not</em> have the text \"View more\".');"
"testString":
"assert(!$(\"a\").text().match(/View\\smore/gi), 'Your <code>a</code> element should <em>not</em> have the text \"View more\".');"
}, },
{ {
"text": "text": "Make sure each of your <code>p</code> elements has a closing tag.",
"Make sure each of your <code>p</code> elements has a closing tag.", "testString": "assert(code.match(/<\\/p>/g) && code.match(/<p/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure each of your <code>p</code> elements has a closing tag.');"
"testString":
"assert(code.match(/<\\/p>/g) && code.match(/<p/g) && code.match(/<\\/p>/g).length === code.match(/<p/g).length, 'Make sure each of your <code>p</code> elements has a closing tag.');"
}, },
{ {
"text": "text": "Make sure each of your <code>a</code> elements has a closing tag.",
"Make sure each of your <code>a</code> elements has a closing tag.", "testString": "assert(code.match(/<\\/a>/g) && code.match(/<a/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure each of your <code>a</code> elements has a closing tag.');"
"testString":
"assert(code.match(/<\\/a>/g) && code.match(/<a/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure each of your <code>a</code> elements has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1189,10 +1107,8 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your <code>a</code> element should be a dead link with the value of the <code>href</code> attribute set to \"#\".",
"Your <code>a</code> element should be a dead link with the value of the <code>href</code> attribute set to \"#\".", "testString": "assert($(\"a\").attr(\"href\") === \"#\", 'Your <code>a</code> element should be a dead link with the value of the <code>href</code> attribute set to \"#\".');"
"testString":
"assert($(\"a\").attr(\"href\") === \"#\", 'Your <code>a</code> element should be a dead link with the value of the <code>href</code> attribute set to \"#\".');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1269,22 +1185,16 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Nest the existing <code>img</code> element within an <code>a</code> element.",
"Nest the existing <code>img</code> element within an <code>a</code> element.", "testString": "assert($(\"a\").children(\"img\").length > 0, 'Nest the existing <code>img</code> element within an <code>a</code> element.');"
"testString":
"assert($(\"a\").children(\"img\").length > 0, 'Nest the existing <code>img</code> element within an <code>a</code> element.');"
}, },
{ {
"text": "text": "Your <code>a</code> element should be a dead link with a <code>href</code> attribute set to <code>#</code>.",
"Your <code>a</code> element should be a dead link with a <code>href</code> attribute set to <code>#</code>.", "testString": "assert(new RegExp(\"#\").test($(\"a\").children(\"img\").parent().attr(\"href\")), 'Your <code>a</code> element should be a dead link with a <code>href</code> attribute set to <code>#</code>.');"
"testString":
"assert(new RegExp(\"#\").test($(\"a\").children(\"img\").parent().attr(\"href\")), 'Your <code>a</code> element should be a dead link with a <code>href</code> attribute set to <code>#</code>.');"
}, },
{ {
"text": "text": "Make sure each of your <code>a</code> elements has a closing tag.",
"Make sure each of your <code>a</code> elements has a closing tag.", "testString": "assert(code.match(/<\\/a>/g) && code.match(/<a/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure each of your <code>a</code> elements has a closing tag.');"
"testString":
"assert(code.match(/<\\/a>/g) && code.match(/<a/g) && code.match(/<\\/a>/g).length === code.match(/<a/g).length, 'Make sure each of your <code>a</code> elements has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1371,24 +1281,19 @@
"tests": [ "tests": [
{ {
"text": "Create a <code>ul</code> element.", "text": "Create a <code>ul</code> element.",
"testString": "testString": "assert($(\"ul\").length > 0, 'Create a <code>ul</code> element.');"
"assert($(\"ul\").length > 0, 'Create a <code>ul</code> element.');"
}, },
{ {
"text": "text": "You should have three <code>li</code> elements within your <code>ul</code> element.",
"You should have three <code>li</code> elements within your <code>ul</code> element.", "testString": "assert($(\"ul li\").length > 2, 'You should have three <code>li</code> elements within your <code>ul</code> element.');"
"testString":
"assert($(\"ul li\").length > 2, 'You should have three <code>li</code> elements within your <code>ul</code> element.');"
}, },
{ {
"text": "Make sure your <code>ul</code> element has a closing tag.", "text": "Make sure your <code>ul</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/ul>/gi) && code.match(/<ul/gi) && code.match(/<\\/ul>/gi).length === code.match(/<ul/gi).length, 'Make sure your <code>ul</code> element has a closing tag.');"
"assert(code.match(/<\\/ul>/gi) && code.match(/<ul/gi) && code.match(/<\\/ul>/gi).length === code.match(/<ul/gi).length, 'Make sure your <code>ul</code> element has a closing tag.');"
}, },
{ {
"text": "Make sure your <code>li</code> elements have closing tags.", "text": "Make sure your <code>li</code> elements have closing tags.",
"testString": "testString": "assert(code.match(/<\\/li>/gi) && code.match(/<li[\\s>]/gi) && code.match(/<\\/li>/gi).length === code.match(/<li[\\s>]/gi).length, 'Make sure your <code>li</code> elements have closing tags.');"
"assert(code.match(/<\\/li>/gi) && code.match(/<li[\\s>]/gi) && code.match(/<\\/li>/gi).length === code.match(/<li[\\s>]/gi).length, 'Make sure your <code>li</code> elements have closing tags.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1477,52 +1382,40 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "You should have an ordered list for \"Top 3 things cats hate:\"",
"You should have an ordered list for \"Top 3 things cats hate:\"", "testString": "assert((/Top 3 things cats hate:/i).test($(\"ol\").prev().text()), 'You should have an ordered list for \"Top 3 things cats hate:\"');"
"testString":
"assert((/Top 3 things cats hate:/i).test($(\"ol\").prev().text()), 'You should have an ordered list for \"Top 3 things cats hate:\"');"
}, },
{ {
"text": "You should have an unordered list for \"Things cats love:\"", "text": "You should have an unordered list for \"Things cats love:\"",
"testString": "testString": "assert((/Things cats love:/i).test($(\"ul\").prev().text()), 'You should have an unordered list for \"Things cats love:\"');"
"assert((/Things cats love:/i).test($(\"ul\").prev().text()), 'You should have an unordered list for \"Things cats love:\"');"
}, },
{ {
"text": "You should have only one <code>ul</code> element.", "text": "You should have only one <code>ul</code> element.",
"testString": "testString": "assert.equal($(\"ul\").length, 1, 'You should have only one <code>ul</code> element.');"
"assert.equal($(\"ul\").length, 1, 'You should have only one <code>ul</code> element.');"
}, },
{ {
"text": "You should have only one <code>ol</code> element.", "text": "You should have only one <code>ol</code> element.",
"testString": "testString": "assert.equal($(\"ol\").length, 1, 'You should have only one <code>ol</code> element.');"
"assert.equal($(\"ol\").length, 1, 'You should have only one <code>ol</code> element.');"
}, },
{ {
"text": "text": "You should have three <code>li</code> elements within your <code>ul</code> element.",
"You should have three <code>li</code> elements within your <code>ul</code> element.", "testString": "assert.equal($(\"ul li\").length, 3, 'You should have three <code>li</code> elements within your <code>ul</code> element.');"
"testString":
"assert.equal($(\"ul li\").length, 3, 'You should have three <code>li</code> elements within your <code>ul</code> element.');"
}, },
{ {
"text": "text": "You should have three <code>li</code> elements within your <code>ol</code> element.",
"You should have three <code>li</code> elements within your <code>ol</code> element.", "testString": "assert.equal($(\"ol li\").length, 3, 'You should have three <code>li</code> elements within your <code>ol</code> element.');"
"testString":
"assert.equal($(\"ol li\").length, 3, 'You should have three <code>li</code> elements within your <code>ol</code> element.');"
}, },
{ {
"text": "Make sure your <code>ul</code> element has a closing tag.", "text": "Make sure your <code>ul</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/ul>/g) && code.match(/<\\/ul>/g).length === code.match(/<ul>/g).length, 'Make sure your <code>ul</code> element has a closing tag.');"
"assert(code.match(/<\\/ul>/g) && code.match(/<\\/ul>/g).length === code.match(/<ul>/g).length, 'Make sure your <code>ul</code> element has a closing tag.');"
}, },
{ {
"text": "Make sure your <code>ol</code> element has a closing tag.", "text": "Make sure your <code>ol</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/ol>/g) && code.match(/<\\/ol>/g).length === code.match(/<ol>/g).length, 'Make sure your <code>ol</code> element has a closing tag.');"
"assert(code.match(/<\\/ol>/g) && code.match(/<\\/ol>/g).length === code.match(/<ol>/g).length, 'Make sure your <code>ol</code> element has a closing tag.');"
}, },
{ {
"text": "Make sure your <code>li</code> element has a closing tag.", "text": "Make sure your <code>li</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/li>/g) && code.match(/<li>/g) && code.match(/<\\/li>/g).length === code.match(/<li>/g).length, 'Make sure your <code>li</code> element has a closing tag.');"
"assert(code.match(/<\\/li>/g) && code.match(/<li>/g) && code.match(/<\\/li>/g).length === code.match(/<li>/g).length, 'Make sure your <code>li</code> element has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1617,10 +1510,8 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your app should have an <code>input</code> element of type <code>text</code>.",
"Your app should have an <code>input</code> element of type <code>text</code>.", "testString": "assert($(\"input[type=text]\").length > 0, 'Your app should have an <code>input</code> element of type <code>text</code>.');"
"testString":
"assert($(\"input[type=text]\").length > 0, 'Your app should have an <code>input</code> element of type <code>text</code>.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1719,22 +1610,16 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Add a <code>placeholder</code> attribute to the existing text <code>input</code> element.",
"Add a <code>placeholder</code> attribute to the existing text <code>input</code> element.", "testString": "assert($(\"input[placeholder]\").length > 0, 'Add a <code>placeholder</code> attribute to the existing text <code>input</code> element.');"
"testString":
"assert($(\"input[placeholder]\").length > 0, 'Add a <code>placeholder</code> attribute to the existing text <code>input</code> element.');"
}, },
{ {
"text": "text": "Set the value of your placeholder attribute to \"cat photo URL\".",
"Set the value of your placeholder attribute to \"cat photo URL\".", "testString": "assert($(\"input\") && $(\"input\").attr(\"placeholder\") && $(\"input\").attr(\"placeholder\").match(/cat\\s+photo\\s+URL/gi), 'Set the value of your placeholder attribute to \"cat photo URL\".');"
"testString":
"assert($(\"input\") && $(\"input\").attr(\"placeholder\") && $(\"input\").attr(\"placeholder\").match(/cat\\s+photo\\s+URL/gi), 'Set the value of your placeholder attribute to \"cat photo URL\".');"
}, },
{ {
"text": "text": "The finished <code>input</code> element should have valid syntax.",
"The finished <code>input</code> element should have valid syntax.", "testString": "assert($(\"input[type=text]\").length > 0 && code.match(/<input((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[\\^'\">\\s]+))?)+\\s*|\\s*)\\/?>/gi), 'The finished <code>input</code> element should have valid syntax.');"
"testString":
"assert($(\"input[type=text]\").length > 0 && code.match(/<input((\\s+\\w+(\\s*=\\s*(?:\".*?\"|'.*?'|[\\^'\">\\s]+))?)+\\s*|\\s*)\\/?>/gi), 'The finished <code>input</code> element should have valid syntax.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1780,8 +1665,7 @@
] ]
} }
}, },
"guideUrl": "guideUrl": "https://guide.freecodecamp.org/certificates/add-placeholder-text-to-a-text-field",
"https://guide.freecodecamp.org/certificates/add-placeholder-text-to-a-text-field",
"files": { "files": {
"indexhtml": { "indexhtml": {
"key": "indexhtml", "key": "indexhtml",
@ -1826,22 +1710,16 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Nest your text input element within a <code>form</code> element.",
"Nest your text input element within a <code>form</code> element.", "testString": "assert($(\"form\") && $(\"form\").children(\"input\") && $(\"form\").children(\"input\").length > 0, 'Nest your text input element within a <code>form</code> element.');"
"testString":
"assert($(\"form\") && $(\"form\").children(\"input\") && $(\"form\").children(\"input\").length > 0, 'Nest your text input element within a <code>form</code> element.');"
}, },
{ {
"text": "text": "Make sure your <code>form</code> has an <code>action</code> attribute which is set to <code>/submit-cat-photo</code>",
"Make sure your <code>form</code> has an <code>action</code> attribute which is set to <code>/submit-cat-photo</code>", "testString": "assert($(\"form\").attr(\"action\") === \"/submit-cat-photo\", 'Make sure your <code>form</code> has an <code>action</code> attribute which is set to <code>/submit-cat-photo</code>');"
"testString":
"assert($(\"form\").attr(\"action\") === \"/submit-cat-photo\", 'Make sure your <code>form</code> has an <code>action</code> attribute which is set to <code>/submit-cat-photo</code>');"
}, },
{ {
"text": "text": "Make sure your <code>form</code> element has well-formed open and close tags.",
"Make sure your <code>form</code> element has well-formed open and close tags.", "testString": "assert(code.match(/<\\/form>/g) && code.match(/<form [^<]*>/g) && code.match(/<\\/form>/g).length === code.match(/<form [^<]*>/g).length, 'Make sure your <code>form</code> element has well-formed open and close tags.');"
"testString":
"assert(code.match(/<\\/form>/g) && code.match(/<form [^<]*>/g) && code.match(/<\\/form>/g).length === code.match(/<form [^<]*>/g).length, 'Make sure your <code>form</code> element has well-formed open and close tags.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1932,25 +1810,19 @@
"tests": [ "tests": [
{ {
"text": "Your form should have a button inside it.", "text": "Your form should have a button inside it.",
"testString": "testString": "assert($(\"form\").children(\"button\").length > 0, 'Your form should have a button inside it.');"
"assert($(\"form\").children(\"button\").length > 0, 'Your form should have a button inside it.');"
}, },
{ {
"text": "text": "Your submit button should have the attribute <code>type</code> set to <code>submit</code>.",
"Your submit button should have the attribute <code>type</code> set to <code>submit</code>.", "testString": "assert($(\"button\").attr(\"type\") === \"submit\", 'Your submit button should have the attribute <code>type</code> set to <code>submit</code>.');"
"testString":
"assert($(\"button\").attr(\"type\") === \"submit\", 'Your submit button should have the attribute <code>type</code> set to <code>submit</code>.');"
}, },
{ {
"text": "Your submit button should only have the text \"Submit\".", "text": "Your submit button should only have the text \"Submit\".",
"testString": "testString": "assert($(\"button\").text().match(/^\\s*submit\\s*$/gi), 'Your submit button should only have the text \"Submit\".');"
"assert($(\"button\").text().match(/^\\s*submit\\s*$/gi), 'Your submit button should only have the text \"Submit\".');"
}, },
{ {
"text": "text": "Make sure your <code>button</code> element has a closing tag.",
"Make sure your <code>button</code> element has a closing tag.", "testString": "assert(code.match(/<\\/button>/g) && code.match(/<button/g) && code.match(/<\\/button>/g).length === code.match(/<button/g).length, 'Make sure your <code>button</code> element has a closing tag.');"
"testString":
"assert(code.match(/<\\/button>/g) && code.match(/<button/g) && code.match(/<\\/button>/g).length === code.match(/<button/g).length, 'Make sure your <code>button</code> element has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -1996,8 +1868,7 @@
] ]
} }
}, },
"guideUrl": "guideUrl": "https://guide.freecodecamp.org/certificates/add-a-submit-button-to-a-form",
"https://guide.freecodecamp.org/certificates/add-a-submit-button-to-a-form",
"files": { "files": {
"indexhtml": { "indexhtml": {
"key": "indexhtml", "key": "indexhtml",
@ -2044,10 +1915,8 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your text <code>input</code> element should have the <code>required</code> attribute.",
"Your text <code>input</code> element should have the <code>required</code> attribute.", "testString": "assert($(\"input\").prop(\"required\"), 'Your text <code>input</code> element should have the <code>required</code> attribute.');"
"testString":
"assert($(\"input\").prop(\"required\"), 'Your text <code>input</code> element should have the <code>required</code> attribute.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2086,8 +1955,7 @@
] ]
}, },
"ru": { "ru": {
"title": "title": "Используйте HTML5, чтобы сделать заполнение поля обязательным",
"Используйте HTML5, чтобы сделать заполнение поля обязательным",
"description": [ "description": [
"Вы можете требовать заполнения определённых полей формы, таким образом пользователь не сможет отправить данные формы до их заполнения.", "Вы можете требовать заполнения определённых полей формы, таким образом пользователь не сможет отправить данные формы до их заполнения.",
"Например, если бы вы хотели сделать заполнение текстового поля обязательным, вы могли бы добавить слово <code>required</code> внутрь вашего элемента <code>input</code>: <code>&#60;input type=\"text\" required&#62;</code>", "Например, если бы вы хотели сделать заполнение текстового поля обязательным, вы могли бы добавить слово <code>required</code> внутрь вашего элемента <code>input</code>: <code>&#60;input type=\"text\" required&#62;</code>",
@ -2151,44 +2019,31 @@
"tests": [ "tests": [
{ {
"text": "Your page should have two radio button elements.", "text": "Your page should have two radio button elements.",
"testString": "testString": "assert($('input[type=\"radio\"]').length > 1, 'Your page should have two radio button elements.');"
"assert($('input[type=\"radio\"]').length > 1, 'Your page should have two radio button elements.');"
}, },
{ {
"text": "text": "Give your radio buttons the <code>name</code> attribute of <code>indoor-outdoor</code>.",
"Give your radio buttons the <code>name</code> attribute of <code>indoor-outdoor</code>.", "testString": "assert($('label > input[type=\"radio\"]').filter(\"[name='indoor-outdoor']\").length > 1, 'Give your radio buttons the <code>name</code> attribute of <code>indoor-outdoor</code>.');"
"testString":
"assert($('label > input[type=\"radio\"]').filter(\"[name='indoor-outdoor']\").length > 1, 'Give your radio buttons the <code>name</code> attribute of <code>indoor-outdoor</code>.');"
}, },
{ {
"text": "text": "Each of your two radio button elements should be nested in its own <code>label</code> element.",
"Each of your two radio button elements should be nested in its own <code>label</code> element.", "testString": "assert($('label > input[type=\"radio\"]:only-child').length > 1, 'Each of your two radio button elements should be nested in its own <code>label</code> element.');"
"testString":
"assert($('label > input[type=\"radio\"]:only-child').length > 1, 'Each of your two radio button elements should be nested in its own <code>label</code> element.');"
}, },
{ {
"text": "text": "Make sure each of your <code>label</code> elements has a closing tag.",
"Make sure each of your <code>label</code> elements has a closing tag.", "testString": "assert((code.match(/<\\/label>/g) && code.match(/<label/g) && code.match(/<\\/label>/g).length === code.match(/<label/g).length), 'Make sure each of your <code>label</code> elements has a closing tag.');"
"testString":
"assert((code.match(/<\\/label>/g) && code.match(/<label/g) && code.match(/<\\/label>/g).length === code.match(/<label/g).length), 'Make sure each of your <code>label</code> elements has a closing tag.');"
}, },
{ {
"text": "text": "One of your radio buttons should have the label <code>indoor</code>.",
"One of your radio buttons should have the label <code>indoor</code>.", "testString": "assert($(\"label\").text().match(/indoor/gi), 'One of your radio buttons should have the label <code>indoor</code>.');"
"testString":
"assert($(\"label\").text().match(/indoor/gi), 'One of your radio buttons should have the label <code>indoor</code>.');"
}, },
{ {
"text": "text": "One of your radio buttons should have the label <code>outdoor</code>.",
"One of your radio buttons should have the label <code>outdoor</code>.", "testString": "assert($(\"label\").text().match(/outdoor/gi), 'One of your radio buttons should have the label <code>outdoor</code>.');"
"testString":
"assert($(\"label\").text().match(/outdoor/gi), 'One of your radio buttons should have the label <code>outdoor</code>.');"
}, },
{ {
"text": "text": "Each of your radio button elements should be added within the <code>form</code> tag.",
"Each of your radio button elements should be added within the <code>form</code> tag.", "testString": "assert($(\"label\").parent().get(0).tagName.match('FORM'), 'Each of your radio button elements should be added within the <code>form</code> tag.');"
"testString":
"assert($(\"label\").parent().get(0).tagName.match('FORM'), 'Each of your radio button elements should be added within the <code>form</code> tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2298,26 +2153,19 @@
"tests": [ "tests": [
{ {
"text": "Your page should have three checkbox elements.", "text": "Your page should have three checkbox elements.",
"testString": "testString": "assert($('input[type=\"checkbox\"]').length > 2, 'Your page should have three checkbox elements.');"
"assert($('input[type=\"checkbox\"]').length > 2, 'Your page should have three checkbox elements.');"
}, },
{ {
"text": "text": "Each of your three checkbox elements should be nested in its own <code>label</code> element.",
"Each of your three checkbox elements should be nested in its own <code>label</code> element.", "testString": "assert($('label > input[type=\"checkbox\"]:only-child').length > 2, 'Each of your three checkbox elements should be nested in its own <code>label</code> element.');"
"testString":
"assert($('label > input[type=\"checkbox\"]:only-child').length > 2, 'Each of your three checkbox elements should be nested in its own <code>label</code> element.');"
}, },
{ {
"text": "text": "Make sure each of your <code>label</code> elements has a closing tag.",
"Make sure each of your <code>label</code> elements has a closing tag.", "testString": "assert(code.match(/<\\/label>/g) && code.match(/<label/g) && code.match(/<\\/label>/g).length === code.match(/<label/g).length, 'Make sure each of your <code>label</code> elements has a closing tag.');"
"testString":
"assert(code.match(/<\\/label>/g) && code.match(/<label/g) && code.match(/<\\/label>/g).length === code.match(/<label/g).length, 'Make sure each of your <code>label</code> elements has a closing tag.');"
}, },
{ {
"text": "text": "Give your checkboxes the <code>name</code> attribute of <code>personality</code>.",
"Give your checkboxes the <code>name</code> attribute of <code>personality</code>.", "testString": "assert($('label > input[type=\"checkbox\"]').filter(\"[name='personality']\").length > 2, 'Give your checkboxes the <code>name</code> attribute of <code>personality</code>.');"
"testString":
"assert($('label > input[type=\"checkbox\"]').filter(\"[name='personality']\").length > 2, 'Give your checkboxes the <code>name</code> attribute of <code>personality</code>.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2424,16 +2272,12 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your first radio button on your form should be checked by default.",
"Your first radio button on your form should be checked by default.", "testString": "assert($('input[type=\"radio\"]').prop(\"checked\"), 'Your first radio button on your form should be checked by default.');"
"testString":
"assert($('input[type=\"radio\"]').prop(\"checked\"), 'Your first radio button on your form should be checked by default.');"
}, },
{ {
"text": "text": "Your first checkbox on your form should be checked by default.",
"Your first checkbox on your form should be checked by default.", "testString": "assert($('input[type=\"checkbox\"]').prop(\"checked\"), 'Your first checkbox on your form should be checked by default.');"
"testString":
"assert($('input[type=\"checkbox\"]').prop(\"checked\"), 'Your first checkbox on your form should be checked by default.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2449,8 +2293,7 @@
] ]
}, },
"es": { "es": {
"title": "title": "Marca botones de radio y casillas de verificación por omisión",
"Marca botones de radio y casillas de verificación por omisión",
"description": [ "description": [
"Puedes marcar por omisión una casilla de verificación o un botón de radio usando el atributo <code>checked</code>.", "Puedes marcar por omisión una casilla de verificación o un botón de radio usando el atributo <code>checked</code>.",
"Para ello, sólo tienes que añadir la palabra \"checked\" en el interior de un elemento <code>input</code>. Por ejemplo:", "Para ello, sólo tienes que añadir la palabra \"checked\" en el interior de un elemento <code>input</code>. Por ejemplo:",
@ -2460,8 +2303,7 @@
] ]
}, },
"pt-br": { "pt-br": {
"title": "title": "Faça botões de opção e caixas de seleção estarem marcados por padrão",
"Faça botões de opção e caixas de seleção estarem marcados por padrão",
"description": [ "description": [
"Você pode fazer uma caixa de seleção ou botão de opção estar marcado por padrão usando o atributo <code>checked</code>.", "Você pode fazer uma caixa de seleção ou botão de opção estar marcado por padrão usando o atributo <code>checked</code>.",
"Para fazer isso, apenas insira a palavra \"checked\" em um elemento <code>input</code>. Por exemplo:", "Para fazer isso, apenas insira a palavra \"checked\" em um elemento <code>input</code>. Por exemplo:",
@ -2534,27 +2376,20 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Nest your <code>p</code> elements inside your <code>div</code> element.",
"Nest your <code>p</code> elements inside your <code>div</code> element.", "testString": "assert($(\"div\").children(\"p\").length > 1, 'Nest your <code>p</code> elements inside your <code>div</code> element.');"
"testString":
"assert($(\"div\").children(\"p\").length > 1, 'Nest your <code>p</code> elements inside your <code>div</code> element.');"
}, },
{ {
"text": "text": "Nest your <code>ul</code> element inside your <code>div</code> element.",
"Nest your <code>ul</code> element inside your <code>div</code> element.", "testString": "assert($(\"div\").children(\"ul\").length > 0, 'Nest your <code>ul</code> element inside your <code>div</code> element.');"
"testString":
"assert($(\"div\").children(\"ul\").length > 0, 'Nest your <code>ul</code> element inside your <code>div</code> element.');"
}, },
{ {
"text": "text": "Nest your <code>ol</code> element inside your <code>div</code> element.",
"Nest your <code>ol</code> element inside your <code>div</code> element.", "testString": "assert($(\"div\").children(\"ol\").length > 0, 'Nest your <code>ol</code> element inside your <code>div</code> element.');"
"testString":
"assert($(\"div\").children(\"ol\").length > 0, 'Nest your <code>ol</code> element inside your <code>div</code> element.');"
}, },
{ {
"text": "Make sure your <code>div</code> element has a closing tag.", "text": "Make sure your <code>div</code> element has a closing tag.",
"testString": "testString": "assert(code.match(/<\\/div>/g) && code.match(/<\\/div>/g).length === code.match(/<div>/g).length, 'Make sure your <code>div</code> element has a closing tag.');"
"assert(code.match(/<\\/div>/g) && code.match(/<\\/div>/g).length === code.match(/<div>/g).length, 'Make sure your <code>div</code> element has a closing tag.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2661,21 +2496,16 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "Your code should include a <code>&lt;!DOCTYPE html&gt;</code> tag.",
"Your code should include a <code>&lt;!DOCTYPE html&gt;</code> tag.", "testString": "assert(code.match(/<!DOCTYPE\\s+?html\\s*?>/gi), 'Your code should include a <code>&lt;!DOCTYPE html&gt;</code> tag.');"
"testString":
"assert(code.match(/<!DOCTYPE\\s+?html\\s*?>/gi), 'Your code should include a <code>&lt;!DOCTYPE html&gt;</code> tag.');"
}, },
{ {
"text": "There should be one <code>html</code> element.", "text": "There should be one <code>html</code> element.",
"testString": "testString": "assert($('html').length == 1, 'There should be one <code>html</code> element.');"
"assert($('html').length == 1, 'There should be one <code>html</code> element.');"
}, },
{ {
"text": "text": "The <code>html</code> tags should wrap around one <code>h1</code> element.",
"The <code>html</code> tags should wrap around one <code>h1</code> element.", "testString": "assert(code.match(/<html>\\s*?<h1>\\s*?.*?\\s*?<\\/h1>\\s*?<\\/html>/gi), 'The <code>html</code> tags should wrap around one <code>h1</code> element.');"
"testString":
"assert(code.match(/<html>\\s*?<h1>\\s*?.*?\\s*?<\\/h1>\\s*?<\\/html>/gi), 'The <code>html</code> tags should wrap around one <code>h1</code> element.');"
} }
], ],
"challengeType": 0, "challengeType": 0,
@ -2719,40 +2549,28 @@
], ],
"tests": [ "tests": [
{ {
"text": "text": "There should be only one <code>head</code> element on the page.",
"There should be only one <code>head</code> element on the page.", "testString": "assert($('head').length == 1, 'There should be only one <code>head</code> element on the page.');"
"testString":
"assert($('head').length == 1, 'There should be only one <code>head</code> element on the page.');"
}, },
{ {
"text": "text": "There should be only one <code>body</code> element on the page.",
"There should be only one <code>body</code> element on the page.", "testString": "assert($('body').length == 1, 'There should be only one <code>body</code> element on the page.');"
"testString":
"assert($('body').length == 1, 'There should be only one <code>body</code> element on the page.');"
}, },
{ {
"text": "text": "The <code>head</code> element should be a child of the <code>html</code> element.",
"The <code>head</code> element should be a child of the <code>html</code> element.", "testString": "assert($('html').children('head').length == 1, 'The <code>head</code> element should be a child of the <code>html</code> element.');"
"testString":
"assert($('html').children('head').length == 1, 'The <code>head</code> element should be a child of the <code>html</code> element.');"
}, },
{ {
"text": "text": "The <code>body</code> element should be a child of the <code>html</code> element.",
"The <code>body</code> element should be a child of the <code>html</code> element.", "testString": "assert($('html').children('body').length == 1, 'The <code>body</code> element should be a child of the <code>html</code> element.');"
"testString":
"assert($('html').children('body').length == 1, 'The <code>body</code> element should be a child of the <code>html</code> element.');"
}, },
{ {
"text": "text": "The <code>head</code> element should wrap around the <code>title</code> element.",
"The <code>head</code> element should wrap around the <code>title</code> element.", "testString": "assert(code.match(/<head>\\s*?<title>\\s*?.*?\\s*?<\\/title>\\s*?<\\/head>/gi), 'The <code>head</code> element should wrap around the <code>title</code> element.');"
"testString":
"assert(code.match(/<head>\\s*?<title>\\s*?.*?\\s*?<\\/title>\\s*?<\\/head>/gi), 'The <code>head</code> element should wrap around the <code>title</code> element.');"
}, },
{ {
"text": "text": "The <code>body</code> element should wrap around both the <code>h1</code> and <code>p</code> elements.",
"The <code>body</code> element should wrap around both the <code>h1</code> and <code>p</code> elements.", "testString": "assert($('body').children('h1').length == 1 && $('body').children('p').length == 1, 'The <code>body</code> element should wrap around both the <code>h1</code> and <code>p</code> elements.');"
"testString":
"assert($('body').children('h1').length == 1 && $('body').children('p').length == 1, 'The <code>body</code> element should wrap around both the <code>h1</code> and <code>p</code> elements.');"
} }
], ],
"challengeType": 0, "challengeType": 0,