| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | --- | 
					
						
							|  |  |  | id: bad87fee1348bd9aedf08828 | 
					
						
							|  |  |  | title: Create an Ordered List | 
					
						
							|  |  |  | challengeType: 0 | 
					
						
							|  |  |  | videoUrl: 'https://scrimba.com/p/pVMPUv/cQ3B8TM' | 
					
						
							| 
									
										
										
										
											2019-07-31 11:32:23 -07:00
										 |  |  | forumTopicId: 16824 | 
					
						
							| 
									
										
										
										
											2021-01-13 03:31:00 +01:00
										 |  |  | dashedName: create-an-ordered-list | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | # --description--
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-27 15:45:37 -01:00
										 |  |  | HTML has another special element for creating <dfn>ordered lists</dfn>, or numbered lists. | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | Ordered lists start with an opening `<ol>` element, followed by any number of `<li>` elements. Finally, ordered lists are closed with the `</ol>` tag. | 
					
						
							| 
									
										
										
										
											2019-03-12 22:53:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | For example: | 
					
						
							| 
									
										
										
										
											2019-05-14 01:11:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <ol> | 
					
						
							|  |  |  |   <li>Garfield</li> | 
					
						
							|  |  |  |   <li>Sylvester</li> | 
					
						
							|  |  |  | </ol> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-01 11:56:07 -08:00
										 |  |  | would create a numbered list of `Garfield` and `Sylvester`. | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | # --instructions--
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | Create an ordered list of the top 3 things cats hate the most. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | # --hints--
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have an ordered list for `Top 3 things cats hate:` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert(/Top 3 things cats hate:/i.test($('ol').prev().text())); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have an unordered list for `Things cats love:` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert(/Things cats love:/i.test($('ul').prev().text())); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have only one `ul` element. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert.equal($('ul').length, 1); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have only one `ol` element. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert.equal($('ol').length, 1); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | You should have three `li` elements within your `ul` element. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert.equal($('ul li').length, 3); | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | You should have three `li` elements within your `ol` element. | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | ```js | 
					
						
							|  |  |  | assert.equal($('ol li').length, 3); | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | Your `ul` element should have a closing tag. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert( | 
					
						
							|  |  |  |   code.match(/<\/ul>/g) && | 
					
						
							|  |  |  |     code.match(/<\/ul>/g).length === code.match(/<ul>/g).length | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Your `ol` element should have a closing tag. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert( | 
					
						
							|  |  |  |   code.match(/<\/ol>/g) && | 
					
						
							|  |  |  |     code.match(/<\/ol>/g).length === code.match(/<ol>/g).length | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Your `li` element should have a closing tag. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | assert( | 
					
						
							|  |  |  |   code.match(/<\/li>/g) && | 
					
						
							|  |  |  |     code.match(/<li>/g) && | 
					
						
							|  |  |  |     code.match(/<\/li>/g).length === code.match(/<li>/g).length | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `li` elements in your unordered list should not be empty. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | $('ul li').each((i, val) => | 
					
						
							|  |  |  |   assert(__helpers.removeWhiteSpace(val.textContent)) | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | The `li` elements in your ordered list should not be empty. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | $('ol li').each((i, val) => | 
					
						
							|  |  |  |   assert(!!__helpers.removeWhiteSpace(val.textContent)) | 
					
						
							|  |  |  | ); | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # --seed--
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## --seed-contents--
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```html | 
					
						
							|  |  |  | <h2>CatPhotoApp</h2> | 
					
						
							|  |  |  | <main> | 
					
						
							|  |  |  |   <p>Click here to view more <a href="#">cat photos</a>.</p> | 
					
						
							| 
									
										
										
										
											2018-10-08 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-26 19:04:53 +02:00
										 |  |  |   <a href="#"><img src="https://www.bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a> | 
					
						
							| 
									
										
										
										
											2018-10-08 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  |   <p>Things cats love:</p> | 
					
						
							|  |  |  |   <ul> | 
					
						
							|  |  |  |     <li>cat nip</li> | 
					
						
							|  |  |  |     <li>laser pointers</li> | 
					
						
							|  |  |  |     <li>lasagna</li> | 
					
						
							|  |  |  |   </ul> | 
					
						
							|  |  |  |   <p>Top 3 things cats hate:</p> | 
					
						
							| 
									
										
										
										
											2018-10-08 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | </main> | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-27 19:02:05 +01:00
										 |  |  | # --solutions--
 | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-01 13:20:09 -05:00
										 |  |  | ```html | 
					
						
							|  |  |  | <h2>CatPhotoApp</h2> | 
					
						
							|  |  |  | <main> | 
					
						
							|  |  |  |   <p>Click here to view more <a href="#">cat photos</a>.</p> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-26 19:04:53 +02:00
										 |  |  |   <a href="#"><img src="https://www.bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back."></a> | 
					
						
							| 
									
										
										
										
											2019-03-01 13:20:09 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   <p>Things cats love:</p> | 
					
						
							|  |  |  |   <ul> | 
					
						
							|  |  |  |     <li>cat nip</li> | 
					
						
							|  |  |  |     <li>laser pointers</li> | 
					
						
							|  |  |  |     <li>lasagna</li> | 
					
						
							|  |  |  |   </ul> | 
					
						
							|  |  |  |   <p>Top 3 things cats hate:</p> | 
					
						
							|  |  |  |   <ol> | 
					
						
							|  |  |  |     <li>hate 1</li> | 
					
						
							|  |  |  |     <li>hate 2</li> | 
					
						
							|  |  |  |     <li>hate 3</li> | 
					
						
							|  |  |  |   </ol> | 
					
						
							|  |  |  | </main> | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | ``` |