| 
									
										
										
										
											2018-09-30 23:01:58 +01:00
										 |  |  | --- | 
					
						
							|  |  |  | id: cf1111c1c11feddfaeb3bdef | 
					
						
							|  |  |  | title: Add Two Numbers with JavaScript | 
					
						
							|  |  |  | challengeType: 1 | 
					
						
							| 
									
										
										
										
											2019-02-14 12:24:02 -05:00
										 |  |  | videoUrl: 'https://scrimba.com/c/cM2KBAG' | 
					
						
							| 
									
										
										
										
											2018-09-30 23:01:58 +01:00
										 |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Description
 | 
					
						
							|  |  |  | <section id='description'> | 
					
						
							|  |  |  | <code>Number</code> is a data type in JavaScript which represents numeric data. | 
					
						
							|  |  |  | Now let's try to add two numbers using JavaScript. | 
					
						
							| 
									
										
										
										
											2019-03-12 18:05:22 -04:00
										 |  |  | JavaScript uses the <code>+</code> symbol as an addition operator when placed between two numbers. | 
					
						
							| 
									
										
										
										
											2019-02-05 17:44:05 +02:00
										 |  |  | <strong>Example:</strong> | 
					
						
							| 
									
										
										
										
											2018-09-30 23:01:58 +01:00
										 |  |  | <blockquote>myVar = 5 + 10; // assigned 15</blockquote> | 
					
						
							|  |  |  | </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Instructions
 | 
					
						
							|  |  |  | <section id='instructions'> | 
					
						
							|  |  |  | Change the <code>0</code> so that sum will equal <code>20</code>. | 
					
						
							|  |  |  | </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Tests
 | 
					
						
							|  |  |  | <section id='tests'> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```yml | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  | tests: | 
					
						
							|  |  |  |   - text: <code>sum</code> should equal <code>20</code> | 
					
						
							| 
									
										
										
										
											2018-10-20 21:02:47 +03:00
										 |  |  |     testString: assert(sum === 20, '<code>sum</code> should equal <code>20</code>'); | 
					
						
							| 
									
										
										
										
											2018-10-04 14:37:37 +01:00
										 |  |  |   - text: Use the <code>+</code> operator | 
					
						
							| 
									
										
										
										
											2018-10-20 21:02:47 +03:00
										 |  |  |     testString: assert(/\+/.test(code), 'Use the <code>+</code> operator'); | 
					
						
							| 
									
										
										
										
											2018-09-30 23:01:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Challenge Seed
 | 
					
						
							|  |  |  | <section id='challengeSeed'> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div id='js-seed'> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | var sum = 10 + 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### After Test
 | 
					
						
							|  |  |  | <div id='js-teardown'> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							| 
									
										
										
										
											2018-10-20 21:02:47 +03:00
										 |  |  | (function(z){return 'sum = '+z;})(sum); | 
					
						
							| 
									
										
										
										
											2018-09-30 23:01:58 +01:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Solution
 | 
					
						
							|  |  |  | <section id='solution'> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ```js | 
					
						
							|  |  |  | var sum = 10 + 10; | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | </section> |