├── .gitignore ├── .learn ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── loops.js ├── package-lock.json ├── package.json └── test └── loops-test.js /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node 3 | 4 | ### Node ### 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # node-waf configuration 28 | .lock-wscript 29 | 30 | # Compiled binary addons (http://nodejs.org/api/addons.html) 31 | build/Release 32 | 33 | # Dependency directories 34 | node_modules 35 | jspm_packages 36 | 37 | # Optional npm cache directory 38 | .npm 39 | 40 | # Optional REPL history 41 | .node_repl_history 42 | 43 | .results.json 44 | -------------------------------------------------------------------------------- /.learn: -------------------------------------------------------------------------------- 1 | tags: 2 | - loops 3 | - looping 4 | - readme 5 | languages: 6 | - javascript 7 | resources: 6 -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Learn.co Curriculum 2 | 3 | We're really exited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible. 4 | 5 | ## Raising an Issue to Encourage a Contribution 6 | 7 | If you notice a problem with the curriculum that you believe needs improvement 8 | but you're unable to make the change yourself, you should raise a Github issue 9 | containing a clear description of the problem. Include relevant snippets of 10 | the content and/or screenshots if applicable. Curriculum owners regularly review 11 | issue lists and your issue will be prioritized and addressed as appropriate. 12 | 13 | ## Submitting a Pull Request to Suggest an Improvement 14 | 15 | If you see an opportunity for improvement and can make the change yourself go 16 | ahead and use a typical git workflow to make it happen: 17 | 18 | * Fork this curriculum repository 19 | * Make the change on your fork, with descriptive commits in the standard format 20 | * Open a Pull Request against this repo 21 | 22 | A curriculum owner will review your change and approve or comment on it in due 23 | course. 24 | 25 | # Why Contribute? 26 | 27 | Curriculum on Learn is publicly and freely available under Learn's 28 | [Educational Content License](https://learn.co/content-license). By 29 | embracing an open-source contribution model, our goal is for the curriculum 30 | on Learn to become, in time, the best educational content the world has 31 | ever seen. 32 | 33 | We need help from the community of Learners to maintain and improve the 34 | educational content. Everything from fixing typos, to correcting 35 | out-dated information, to improving exposition, to adding better examples, 36 | to fixing tests—all contributions to making the curriculum more effective are 37 | welcome. -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | #Learn.co Educational Content License 2 | 3 | Copyright (c) 2015 Flatiron School, Inc 4 | 5 | The Flatiron School, Inc. owns this Educational Content. However, the Flatiron School supports the development and availability of educational materials in the public domain. Therefore, the Flatiron School grants Users of the Flatiron Educational Content set forth in this repository certain rights to reuse, build upon and share such Educational Content subject to the terms of the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). You must read carefully the terms and conditions contained in the Educational Content License as such terms govern access to and use of the Educational Content. 6 | 7 | Flatiron School is willing to allow you access to and use of the Educational Content only on the condition that you accept all of the terms and conditions contained in the Educational Content License set forth [here](http://learn.co/content-license) (http://learn.co/content-license). By accessing and/or using the Educational Content, you are agreeing to all of the terms and conditions contained in the Educational Content License. If you do not agree to any or all of the terms of the Educational Content License, you are prohibited from accessing, reviewing or using in any way the Educational Content. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JavaScript Loops 2 | 3 | ## Objectives 4 | 5 | - Build a for loop 6 | - Build a while loop 7 | - Build a do-while loop 8 | - Explain the purpose of a loop 9 | - Explain the difference between each type of loop in JS 10 | 11 | ## Introduction 12 | 13 | Sometimes, we need to do things repeatedly in life - our daily routines, for 14 | example. We wake up every morning. We got to work or school repeatedly. We 15 | repeatedly decide what to watch next on YouTube/Netflix. 16 | 17 | In programming, we also often need to complete tasks repeatedly. Say we wanted 18 | to count from one to five using `console.log`. We _could_ write: 19 | 20 | ```js 21 | console.log(1) 22 | console.log(2) 23 | console.log(3) 24 | console.log(4) 25 | console.log(5) 26 | ``` 27 | 28 | This logs: 29 | 30 | ```js 31 | 1 32 | 2 33 | 3 34 | 4 35 | 5 36 | ``` 37 | 38 | This works, but it is very repetative. Its also 'hardcoded' - that is to say, it 39 | will only work if we want to log the numbers `1` through `5`. We could instead 40 | make this code a bit more abstract and replace the numbers with a variable, 41 | incrementing the variable after each log: 42 | 43 | ```js 44 | let num = 1 45 | console.log(num) 46 | num += 1 47 | console.log(num) 48 | num += 1 49 | console.log(num) 50 | num += 1 51 | console.log(num) 52 | num += 1 53 | console.log(num) 54 | ``` 55 | 56 | This produces the same result as the previous logs, but we now have the ability 57 | to change what number we start counting from. If we assigned `num` to `5` at the 58 | beginning, we would get: 59 | 60 | ```js 61 | 5 62 | 6 63 | 7 64 | 8 65 | 9 66 | ``` 67 | 68 | Cool, but we still have an issue - this code is way to repetitive. In fact, 69 | abstracting the code made it _even more_ repetitive! 70 | 71 | Instead of having to write the same lines over and over, we can use a _loop_. 72 | Loops are used to execute the same block of code a specified number of times. 73 | 74 | In this lesson, we'll take a closer look at loops and see how they can clean up 75 | and simplify our code. This is a code-along, so follow along with the 76 | instructions in each section. There are tests to make sure you are coding your 77 | solutions correctly. 78 | 79 | ## Another Example 80 | 81 | Let's imagine we have a bunch of gifts to wrap and want to use code to keep 82 | track of the process. The gifts all happen to be the same size and shape, so for 83 | every gift, we need to cut a similarly sized piece of wrapping paper, fold it up 84 | over the edges of the gift, tape it together, and add a nice little card. Then 85 | we set the wrapped gift aside and moved onto the next gift. 86 | 87 | In programming terms, we can think of the gifts as an array and the act of 88 | wrapping them as a function. We could, of course, write the following code: 89 | 90 | ```javascript 91 | let gifts = ["teddy bear", "drone", "doll"]; 92 | 93 | function wrapGift(gift) { 94 | console.log(`Wrapped ${gift} and added a bow!`); 95 | } 96 | ``` 97 | 98 | We could then call `wrapGift()` on each gift individually: 99 | 100 | ```javascript 101 | wrapGift(gifts[0]); 102 | wrapGift(gifts[1]); 103 | wrapGift(gifts[2]); 104 | ``` 105 | 106 | But if we had more gifts, we'd have to write out more calls to `wrapGift()` — 107 | it would probably get tiring after a while. 108 | 109 | This is where loops come in handy! With a loop, we can just write the repeated 110 | action _once_ and perform the action on every item in the collection. 111 | 112 | ## About Loops 113 | 114 | JavaScript loops come in a few different flavors — namely, `for`, `while`, and 115 | `do-while`. We'll cover each of these kinds of loop below. 116 | 117 | ## The `for` Loop 118 | 119 | Of the loops in JavaScript, the `for` loop is the most common. The `for` loop is 120 | made up of four statements and has the following structure: 121 | 122 | #### Syntax 123 | 124 | ```javascript 125 | for ([initialization]; [condition]; [iteration]) { 126 | [loopBody]; 127 | } 128 | ``` 129 | 130 | - initialization 131 | - An expression (including assignment expressions) or variable declaration. 132 | Typically used to initialize a counter variable. This expression may optionally 133 | declare new variables with the let keyword 134 | - Condition 135 | - An expression evaluated before each loop iteration. If this expression evaluates 136 | to true, statement is executed 137 | - Iteration 138 | - A statement executed at the end of each iteration. Typically, this will involve 139 | incrementing or decrementing a counter, bringing the loop ever closer to its end 140 | - loopBody 141 | - Code which runs on every iteration as long as the condition evaluates to true 142 | 143 | > Use a `for` loop when you know how many times you want the loop to run (for 144 | > example, when you have an array of known size). 145 | 146 | #### Examples 147 | 148 | Going back to the original counting example, we could use a `for` loop to count 149 | numbers: 150 | 151 | ```js 152 | for (let num = 1; num < 6; num += 1) { 153 | console.log(num) 154 | } 155 | ``` 156 | 157 | The above loop will produce: 158 | 159 | ```js 160 | 1 161 | 2 162 | 3 163 | 4 164 | 5 165 | ``` 166 | 167 | The same results as our initial code! In this loop design, we declare a 168 | variable, `let num = 1`, as the initialization. Then, we establish the 169 | condition, that `num` is _less than_ 6. The third thing we do is define the 170 | iteration - `num += 1`. Combined, these three statements indicate that, starting 171 | at `num = 1`, this loop will execute over and over until the condition is no 172 | longer met. After each loop, `num` is incremented by 1. 173 | 174 | With these configured, all we need to provide inside the loop is a single 175 | `console.log(num)`. If we wanted to, we could change the initial value, the 176 | condition and/or the iteration, giving us good abstraction and flexibility. 177 | 178 | Let's take a look at another, more complex example. The code below will print 179 | the string "Hello World!" 99 times: 180 | 181 | ```javascript 182 | // i is set equal to 1 183 | // as long as i is less than 100 execute the code in the loopBody 184 | // - which is print "Hello World"; increment i each time the code in loopBody is executed 185 | 186 | for (let i = 1; i < 100; i++) { 187 | console.log("Hello World the " + i + " time"); 188 | } 189 | 190 | // The above prints: 191 | // Hello World the 1 time 192 | // Hello World the 2 time 193 | // Hello World the 3 time 194 | ``` 195 | 196 | You'll encounter `for` loops again when you learn about iterating through object 197 | literals. 198 | 199 | Now, let's revisit our gift wrapping example. Given the following array: 200 | 201 | ```js 202 | let gifts = ["teddy bear", "drone", "doll"]; 203 | ``` 204 | 205 | If we wanted to write a function that logged a message for each gift in the 206 | array, we would need to access each element one after the other. Sounds loopy! 207 | 208 | ```js 209 | let gifts = ["teddy bear", "drone", "doll"]; 210 | 211 | for (let i = 0; i < 3; i++) { 212 | console.log(`Wrapped ${gifts[i]} and added a bow!`); 213 | } 214 | ``` 215 | 216 | The above loop will log: 217 | 218 | ```bash 219 | Wrapped teddy bear and added a bow! 220 | Wrapped drone and added a bow! 221 | Wrapped doll and added a bow! 222 | ``` 223 | 224 | This isn't _exactly_ what we want. If we added another gift to the array, we 225 | would have a problem. Since the conditional is `i < 3`, this loop will only 226 | increment `i` from `0` to `1` to `2` and wouldn't log the extra gift. However, if 227 | we _change_ the condition to be based off the length of our array, we'll be in 228 | great shape: 229 | 230 | ```js 231 | let gifts = ["teddy bear", "drone", "doll", "bike"]; 232 | 233 | for (let i = 0; i < gifts.length; i++) { 234 | console.log(`Wrapped ${gifts[i]} and added a bow!`); 235 | } 236 | ``` 237 | 238 | Now, no matter the length of the array, our loop will be able to iterate over 239 | every element. 240 | 241 | To finally wrap up, we can wrap the loop in a function: 242 | 243 | ```js 244 | let gifts = ["teddy bear", "drone", "doll"]; 245 | 246 | function wrapGift(gifts) { 247 | for (let i = 0; i < gifts.length; i++) { 248 | console.log(`Wrapped ${gifts[i]} and added a bow!`); 249 | } 250 | } 251 | 252 | wrapGift(gifts) 253 | ``` 254 | 255 | **TODO**: Build a function `forLoop`. It takes an array as an argument. Start 256 | counting from 0, and, using a `for` loop, add a string to the array 25 times. 257 | Your `for` loop could look something like this: 258 | 259 | ```javascript 260 | for (let i = 0; i < 25; i++) { 261 | // ... 262 | } 263 | ``` 264 | 265 | We don't want just any string. 266 | 267 | - If your `i` value is `1`, add the string `"I am 1 strange loop."` 268 | - If your `i` value is anything else, add the string `"I am ${i} strange loops."` 269 | 270 | Remember flow control with `if` and `else`? And how do we 271 | _interpolate_ `i`? 272 | 273 | Once the loop has finished, return the array full of strings. 274 | 275 | ## The `while` Loop 276 | 277 | The `while` loop is similar to an `if` statement, except that its body will keep 278 | executing until the condition evaluates to false. It has the following 279 | structure: 280 | 281 | #### Syntax 282 | 283 | ```javascript 284 | while ([condition]) { 285 | [loopBody]; 286 | } 287 | ``` 288 | 289 | > A `while` loop is often used when we don't know how many times a loop needs to 290 | > run - that is, the condition is dependent on a dynamic function/return value. 291 | > However, we can actually write any `for` loop as a `while` loop if we choose. 292 | 293 | #### Examples 294 | 295 | Here is our counting example as a `while` loop: 296 | 297 | ```js 298 | let num = 1 299 | 300 | while (num < 6) { 301 | console.log(num) 302 | num += 1 303 | } 304 | ``` 305 | 306 | Notice that in a `for` loop, the initialization, condition and iteration 307 | statements are all contained in the loop syntax. In a `while` loop, all three 308 | statements still exist, but the initialization is _outside_ the loop and the 309 | iteration is _inside_. Only the condition is contained in the loop syntax. 310 | 311 | One common mistake when writing `while` loops - we must always remember to 312 | include the iteration statement (`num += 1`). Otherwise, the loop will run 313 | forever! 314 | 315 | Here is another example, this time, counting down: 316 | 317 | ```js 318 | let countdown = 100; 319 | 320 | while (countdown > 0) { 321 | console.log(--countdown); 322 | } 323 | ``` 324 | 325 | In a more complex example, we can see how `while` loops are handy when we don't 326 | know exactly how many times we need to loop: 327 | 328 | ```javascript 329 | function maybeTrue() { 330 | return Math.random() >= 0.5; // Returns a random number between 0 (inclusive) and 1 (exclusive) 331 | } 332 | 333 | // run until `maybeTrue()` returns `false` 334 | // (so the body of the loop might _never_ run!) 335 | while (maybeTrue()) { 336 | console.log("And I ran; I ran so far away!"); 337 | } 338 | ``` 339 | 340 | In this example, `maybeTrue()` returns `true` 50% of the time, and our loop runs 341 | until `maybeTrue()` returns `false`. We've used a `while` loop because we don't 342 | have any specific number to count up or down to in our loop — we just want it to 343 | run until the condition is no longer met. In this example, it is possible the 344 | condition will be met immediately, causing the loop to _never run_. 345 | 346 | **TODO**: Create a function called `whileLoop` in `loops.js`. The function 347 | should take a number as an argument. Using a `while` loop, count down (using 348 | `console.log`) from the passed in number to 0. Then return the string `'done'`. 349 | 350 | ## The Do-While Loop 351 | 352 | The `do-while` loop is almost exactly the same as the while loop, except for the 353 | fact that the loop's body is executed at least once before the condition is 354 | tested. 355 | 356 | #### Syntax 357 | 358 | The `do-while` loop has the following structure: 359 | 360 | ```javascript 361 | do { 362 | [loopBody]; 363 | } while ([condition]); 364 | ``` 365 | 366 | You will rarely see `do-while` used since very few situations require a loop 367 | that blindly executes at least once. That being said, take a look at the example 368 | below: 369 | 370 | #### Example 371 | 372 | ```javascript 373 | let i = 0; 374 | 375 | function incrementVariable() { 376 | i = i + 1; 377 | return i; 378 | } 379 | 380 | do { 381 | console.log("doo-bee-doo-bee-doo"); 382 | } while (incrementVariable() < 5); 383 | ``` 384 | 385 | Remember how we couldn't be sure with the plain `while` loop above that the body 386 | would run using `maybeTrue()`? With `do`, we _can_ be sure that the body will 387 | run! 388 | 389 | **TODO**: Define a function called `doWhileLoop` in `loops.js`. The function should take 390 | an integer as an argument. Use the `incrementVariable()` function (you can copy it 391 | from this README) in the condition, and console log 392 | `"I run once regardless."` while `incrementVariable()` returns a number less 393 | than the parameter received. (Your condition might look something like 394 | `incrementVariable() < num`.) Remember that it should also console log when 395 | receiving 0 as a parameter because the do-while runs before the condition is 396 | checked. 397 | 398 | ## Conclusion 399 | 400 | If seeing all of these new loops all at once is freaking you out, take a deep 401 | breath. Remember, 98% of the time you will want to use a `for` loop. A general 402 | heuristic for choosing which loop, is try a `for`. If using `for` doesn't serve 403 | your purposes, then go ahead and try a different loop. Also remember that you 404 | can always refer to documentation on these loops at any time. After some time 405 | coding in JavaScript, writing a `for` loop will come as naturally to you as 406 | wrapping one gift after another. 407 | 408 | ## Resources 409 | 410 | - [Codecademy - For Loop](http://www.codecademy.com/glossary/javascript/loops#for-loops) 411 | - [MDN - For Loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for) 412 | - [Codecademy - While Loop](http://www.codecademy.com/glossary/javascript/loops#while-loops) 413 | - [MDN - While Loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while) 414 | - [Codecademy - Do-While Loop](http://www.codecademy.com/glossary/javascript/loops#do-while-loops) 415 | - [MDN - Do-While Loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/do...while) 416 | 417 |

View Javascript Intro To Looping on Learn.co and start learning to code for free.

418 | -------------------------------------------------------------------------------- /loops.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/learn-co-students/javascript-intro-to-looping-bootcamp-prep-000/e0048340c6766e880578fae3a352ccd14f13e180/loops.js -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript-intro-to-looping", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "abab": { 8 | "version": "1.0.4", 9 | "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz", 10 | "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=", 11 | "dev": true 12 | }, 13 | "acorn": { 14 | "version": "4.0.13", 15 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", 16 | "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", 17 | "dev": true 18 | }, 19 | "acorn-globals": { 20 | "version": "3.1.0", 21 | "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-3.1.0.tgz", 22 | "integrity": "sha1-/YJw9x+7SZawBPqIDuXUZXOnMb8=", 23 | "dev": true, 24 | "requires": { 25 | "acorn": "^4.0.4" 26 | } 27 | }, 28 | "ajv": { 29 | "version": "6.11.0", 30 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", 31 | "integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", 32 | "dev": true, 33 | "requires": { 34 | "fast-deep-equal": "^3.1.1", 35 | "fast-json-stable-stringify": "^2.0.0", 36 | "json-schema-traverse": "^0.4.1", 37 | "uri-js": "^4.2.2" 38 | } 39 | }, 40 | "array-equal": { 41 | "version": "1.0.0", 42 | "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", 43 | "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=", 44 | "dev": true 45 | }, 46 | "asn1": { 47 | "version": "0.2.4", 48 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", 49 | "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", 50 | "dev": true, 51 | "requires": { 52 | "safer-buffer": "~2.1.0" 53 | } 54 | }, 55 | "assert-plus": { 56 | "version": "1.0.0", 57 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 58 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", 59 | "dev": true 60 | }, 61 | "assertion-error": { 62 | "version": "1.1.0", 63 | "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", 64 | "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", 65 | "dev": true 66 | }, 67 | "asynckit": { 68 | "version": "0.4.0", 69 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 70 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", 71 | "dev": true 72 | }, 73 | "aws-sign2": { 74 | "version": "0.7.0", 75 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", 76 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", 77 | "dev": true 78 | }, 79 | "aws4": { 80 | "version": "1.9.1", 81 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", 82 | "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", 83 | "dev": true 84 | }, 85 | "balanced-match": { 86 | "version": "1.0.0", 87 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 88 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 89 | "dev": true 90 | }, 91 | "bcrypt-pbkdf": { 92 | "version": "1.0.2", 93 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", 94 | "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", 95 | "dev": true, 96 | "requires": { 97 | "tweetnacl": "^0.14.3" 98 | } 99 | }, 100 | "brace-expansion": { 101 | "version": "1.1.11", 102 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 103 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 104 | "dev": true, 105 | "requires": { 106 | "balanced-match": "^1.0.0", 107 | "concat-map": "0.0.1" 108 | } 109 | }, 110 | "browser-stdout": { 111 | "version": "1.3.1", 112 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", 113 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", 114 | "dev": true 115 | }, 116 | "caseless": { 117 | "version": "0.12.0", 118 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 119 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", 120 | "dev": true 121 | }, 122 | "chai": { 123 | "version": "4.2.0", 124 | "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", 125 | "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", 126 | "dev": true, 127 | "requires": { 128 | "assertion-error": "^1.1.0", 129 | "check-error": "^1.0.2", 130 | "deep-eql": "^3.0.1", 131 | "get-func-name": "^2.0.0", 132 | "pathval": "^1.1.0", 133 | "type-detect": "^4.0.5" 134 | } 135 | }, 136 | "chai-spies": { 137 | "version": "0.7.1", 138 | "resolved": "https://registry.npmjs.org/chai-spies/-/chai-spies-0.7.1.tgz", 139 | "integrity": "sha1-ND2Z9RJEIS6LF+ZLk5lv97LCqbE=", 140 | "dev": true 141 | }, 142 | "check-error": { 143 | "version": "1.0.2", 144 | "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", 145 | "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", 146 | "dev": true 147 | }, 148 | "combined-stream": { 149 | "version": "1.0.8", 150 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", 151 | "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", 152 | "dev": true, 153 | "requires": { 154 | "delayed-stream": "~1.0.0" 155 | } 156 | }, 157 | "commander": { 158 | "version": "2.15.1", 159 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", 160 | "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", 161 | "dev": true 162 | }, 163 | "concat-map": { 164 | "version": "0.0.1", 165 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 166 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 167 | "dev": true 168 | }, 169 | "content-type-parser": { 170 | "version": "1.0.2", 171 | "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz", 172 | "integrity": "sha512-lM4l4CnMEwOLHAHr/P6MEZwZFPJFtAAKgL6pogbXmVZggIqXhdB6RbBtPOTsw2FcXwYhehRGERJmRrjOiIB8pQ==", 173 | "dev": true 174 | }, 175 | "core-util-is": { 176 | "version": "1.0.2", 177 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 178 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", 179 | "dev": true 180 | }, 181 | "cssom": { 182 | "version": "0.3.8", 183 | "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", 184 | "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", 185 | "dev": true 186 | }, 187 | "cssstyle": { 188 | "version": "0.2.37", 189 | "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz", 190 | "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=", 191 | "dev": true, 192 | "requires": { 193 | "cssom": "0.3.x" 194 | } 195 | }, 196 | "dashdash": { 197 | "version": "1.14.1", 198 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 199 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 200 | "dev": true, 201 | "requires": { 202 | "assert-plus": "^1.0.0" 203 | } 204 | }, 205 | "debug": { 206 | "version": "3.1.0", 207 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", 208 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", 209 | "dev": true, 210 | "requires": { 211 | "ms": "2.0.0" 212 | } 213 | }, 214 | "deep-eql": { 215 | "version": "3.0.1", 216 | "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", 217 | "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", 218 | "dev": true, 219 | "requires": { 220 | "type-detect": "^4.0.0" 221 | } 222 | }, 223 | "deep-is": { 224 | "version": "0.1.3", 225 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", 226 | "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", 227 | "dev": true 228 | }, 229 | "delayed-stream": { 230 | "version": "1.0.0", 231 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 232 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 233 | "dev": true 234 | }, 235 | "diff": { 236 | "version": "3.5.0", 237 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", 238 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", 239 | "dev": true 240 | }, 241 | "ecc-jsbn": { 242 | "version": "0.1.2", 243 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", 244 | "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", 245 | "dev": true, 246 | "requires": { 247 | "jsbn": "~0.1.0", 248 | "safer-buffer": "^2.1.0" 249 | } 250 | }, 251 | "escape-string-regexp": { 252 | "version": "1.0.5", 253 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 254 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 255 | "dev": true 256 | }, 257 | "escodegen": { 258 | "version": "1.13.0", 259 | "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.13.0.tgz", 260 | "integrity": "sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==", 261 | "dev": true, 262 | "requires": { 263 | "esprima": "^4.0.1", 264 | "estraverse": "^4.2.0", 265 | "esutils": "^2.0.2", 266 | "optionator": "^0.8.1", 267 | "source-map": "~0.6.1" 268 | } 269 | }, 270 | "esprima": { 271 | "version": "4.0.1", 272 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 273 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 274 | "dev": true 275 | }, 276 | "estraverse": { 277 | "version": "4.3.0", 278 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", 279 | "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", 280 | "dev": true 281 | }, 282 | "esutils": { 283 | "version": "2.0.3", 284 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", 285 | "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", 286 | "dev": true 287 | }, 288 | "extend": { 289 | "version": "3.0.2", 290 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", 291 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", 292 | "dev": true 293 | }, 294 | "extsprintf": { 295 | "version": "1.3.0", 296 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", 297 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", 298 | "dev": true 299 | }, 300 | "fast-deep-equal": { 301 | "version": "3.1.1", 302 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz", 303 | "integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==", 304 | "dev": true 305 | }, 306 | "fast-json-stable-stringify": { 307 | "version": "2.1.0", 308 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 309 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", 310 | "dev": true 311 | }, 312 | "fast-levenshtein": { 313 | "version": "2.0.6", 314 | "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", 315 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", 316 | "dev": true 317 | }, 318 | "forever-agent": { 319 | "version": "0.6.1", 320 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 321 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", 322 | "dev": true 323 | }, 324 | "form-data": { 325 | "version": "2.3.3", 326 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", 327 | "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", 328 | "dev": true, 329 | "requires": { 330 | "asynckit": "^0.4.0", 331 | "combined-stream": "^1.0.6", 332 | "mime-types": "^2.1.12" 333 | } 334 | }, 335 | "fs.realpath": { 336 | "version": "1.0.0", 337 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 338 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 339 | "dev": true 340 | }, 341 | "get-func-name": { 342 | "version": "2.0.0", 343 | "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", 344 | "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", 345 | "dev": true 346 | }, 347 | "getpass": { 348 | "version": "0.1.7", 349 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 350 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 351 | "dev": true, 352 | "requires": { 353 | "assert-plus": "^1.0.0" 354 | } 355 | }, 356 | "glob": { 357 | "version": "7.1.2", 358 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 359 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 360 | "dev": true, 361 | "requires": { 362 | "fs.realpath": "^1.0.0", 363 | "inflight": "^1.0.4", 364 | "inherits": "2", 365 | "minimatch": "^3.0.4", 366 | "once": "^1.3.0", 367 | "path-is-absolute": "^1.0.0" 368 | } 369 | }, 370 | "growl": { 371 | "version": "1.10.5", 372 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", 373 | "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", 374 | "dev": true 375 | }, 376 | "har-schema": { 377 | "version": "2.0.0", 378 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", 379 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", 380 | "dev": true 381 | }, 382 | "har-validator": { 383 | "version": "5.1.3", 384 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", 385 | "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", 386 | "dev": true, 387 | "requires": { 388 | "ajv": "^6.5.5", 389 | "har-schema": "^2.0.0" 390 | } 391 | }, 392 | "has-flag": { 393 | "version": "3.0.0", 394 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 395 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 396 | "dev": true 397 | }, 398 | "he": { 399 | "version": "1.1.1", 400 | "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", 401 | "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", 402 | "dev": true 403 | }, 404 | "html-encoding-sniffer": { 405 | "version": "1.0.2", 406 | "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz", 407 | "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==", 408 | "dev": true, 409 | "requires": { 410 | "whatwg-encoding": "^1.0.1" 411 | } 412 | }, 413 | "http-signature": { 414 | "version": "1.2.0", 415 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", 416 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", 417 | "dev": true, 418 | "requires": { 419 | "assert-plus": "^1.0.0", 420 | "jsprim": "^1.2.2", 421 | "sshpk": "^1.7.0" 422 | } 423 | }, 424 | "iconv-lite": { 425 | "version": "0.4.24", 426 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 427 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 428 | "dev": true, 429 | "requires": { 430 | "safer-buffer": ">= 2.1.2 < 3" 431 | } 432 | }, 433 | "inflight": { 434 | "version": "1.0.6", 435 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 436 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 437 | "dev": true, 438 | "requires": { 439 | "once": "^1.3.0", 440 | "wrappy": "1" 441 | } 442 | }, 443 | "inherits": { 444 | "version": "2.0.4", 445 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 446 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 447 | "dev": true 448 | }, 449 | "is-string": { 450 | "version": "1.0.5", 451 | "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", 452 | "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", 453 | "dev": true 454 | }, 455 | "is-typedarray": { 456 | "version": "1.0.0", 457 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 458 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", 459 | "dev": true 460 | }, 461 | "isstream": { 462 | "version": "0.1.2", 463 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 464 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", 465 | "dev": true 466 | }, 467 | "jsbn": { 468 | "version": "0.1.1", 469 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 470 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", 471 | "dev": true 472 | }, 473 | "jsdom": { 474 | "version": "9.12.0", 475 | "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-9.12.0.tgz", 476 | "integrity": "sha1-6MVG//ywbADUgzyoRBD+1/igl9Q=", 477 | "dev": true, 478 | "requires": { 479 | "abab": "^1.0.3", 480 | "acorn": "^4.0.4", 481 | "acorn-globals": "^3.1.0", 482 | "array-equal": "^1.0.0", 483 | "content-type-parser": "^1.0.1", 484 | "cssom": ">= 0.3.2 < 0.4.0", 485 | "cssstyle": ">= 0.2.37 < 0.3.0", 486 | "escodegen": "^1.6.1", 487 | "html-encoding-sniffer": "^1.0.1", 488 | "nwmatcher": ">= 1.3.9 < 2.0.0", 489 | "parse5": "^1.5.1", 490 | "request": "^2.79.0", 491 | "sax": "^1.2.1", 492 | "symbol-tree": "^3.2.1", 493 | "tough-cookie": "^2.3.2", 494 | "webidl-conversions": "^4.0.0", 495 | "whatwg-encoding": "^1.0.1", 496 | "whatwg-url": "^4.3.0", 497 | "xml-name-validator": "^2.0.1" 498 | } 499 | }, 500 | "json-schema": { 501 | "version": "0.2.3", 502 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 503 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", 504 | "dev": true 505 | }, 506 | "json-schema-traverse": { 507 | "version": "0.4.1", 508 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", 509 | "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", 510 | "dev": true 511 | }, 512 | "json-stringify-safe": { 513 | "version": "5.0.1", 514 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 515 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", 516 | "dev": true 517 | }, 518 | "jsprim": { 519 | "version": "1.4.1", 520 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", 521 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", 522 | "dev": true, 523 | "requires": { 524 | "assert-plus": "1.0.0", 525 | "extsprintf": "1.3.0", 526 | "json-schema": "0.2.3", 527 | "verror": "1.10.0" 528 | } 529 | }, 530 | "levn": { 531 | "version": "0.3.0", 532 | "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", 533 | "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", 534 | "dev": true, 535 | "requires": { 536 | "prelude-ls": "~1.1.2", 537 | "type-check": "~0.3.2" 538 | } 539 | }, 540 | "lodash.once": { 541 | "version": "4.1.1", 542 | "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", 543 | "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=", 544 | "dev": true 545 | }, 546 | "mime-db": { 547 | "version": "1.43.0", 548 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", 549 | "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", 550 | "dev": true 551 | }, 552 | "mime-types": { 553 | "version": "2.1.26", 554 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", 555 | "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", 556 | "dev": true, 557 | "requires": { 558 | "mime-db": "1.43.0" 559 | } 560 | }, 561 | "minimatch": { 562 | "version": "3.0.4", 563 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 564 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 565 | "dev": true, 566 | "requires": { 567 | "brace-expansion": "^1.1.7" 568 | } 569 | }, 570 | "minimist": { 571 | "version": "0.0.8", 572 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 573 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 574 | "dev": true 575 | }, 576 | "mkdirp": { 577 | "version": "0.5.1", 578 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 579 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 580 | "dev": true, 581 | "requires": { 582 | "minimist": "0.0.8" 583 | } 584 | }, 585 | "mocha": { 586 | "version": "5.2.0", 587 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", 588 | "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", 589 | "dev": true, 590 | "requires": { 591 | "browser-stdout": "1.3.1", 592 | "commander": "2.15.1", 593 | "debug": "3.1.0", 594 | "diff": "3.5.0", 595 | "escape-string-regexp": "1.0.5", 596 | "glob": "7.1.2", 597 | "growl": "1.10.5", 598 | "he": "1.1.1", 599 | "minimatch": "3.0.4", 600 | "mkdirp": "0.5.1", 601 | "supports-color": "5.4.0" 602 | } 603 | }, 604 | "mocha-jsdom": { 605 | "version": "1.1.0", 606 | "resolved": "https://registry.npmjs.org/mocha-jsdom/-/mocha-jsdom-1.1.0.tgz", 607 | "integrity": "sha1-4VdvvQYBzInTWKIToOVYXRt8egE=", 608 | "dev": true 609 | }, 610 | "mocha-multi": { 611 | "version": "1.1.3", 612 | "resolved": "https://registry.npmjs.org/mocha-multi/-/mocha-multi-1.1.3.tgz", 613 | "integrity": "sha512-bgjcxvfsMhNaRuXWiudidT8EREN6DRvHdzXqFLOdsLU9+oFTi4qiychVEQ3+TtwL9PwIqaiIastIF/tnVM7NYg==", 614 | "dev": true, 615 | "requires": { 616 | "debug": "^4.1.1", 617 | "is-string": "^1.0.4", 618 | "lodash.once": "^4.1.1", 619 | "mkdirp": "^0.5.1", 620 | "object-assign": "^4.1.1" 621 | }, 622 | "dependencies": { 623 | "debug": { 624 | "version": "4.1.1", 625 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", 626 | "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", 627 | "dev": true, 628 | "requires": { 629 | "ms": "^2.1.1" 630 | } 631 | }, 632 | "ms": { 633 | "version": "2.1.2", 634 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 635 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 636 | "dev": true 637 | } 638 | } 639 | }, 640 | "ms": { 641 | "version": "2.0.0", 642 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 643 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", 644 | "dev": true 645 | }, 646 | "nwmatcher": { 647 | "version": "1.4.4", 648 | "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz", 649 | "integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ==", 650 | "dev": true 651 | }, 652 | "oauth-sign": { 653 | "version": "0.9.0", 654 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", 655 | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", 656 | "dev": true 657 | }, 658 | "object-assign": { 659 | "version": "4.1.1", 660 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 661 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 662 | "dev": true 663 | }, 664 | "once": { 665 | "version": "1.4.0", 666 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 667 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 668 | "dev": true, 669 | "requires": { 670 | "wrappy": "1" 671 | } 672 | }, 673 | "optionator": { 674 | "version": "0.8.3", 675 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", 676 | "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", 677 | "dev": true, 678 | "requires": { 679 | "deep-is": "~0.1.3", 680 | "fast-levenshtein": "~2.0.6", 681 | "levn": "~0.3.0", 682 | "prelude-ls": "~1.1.2", 683 | "type-check": "~0.3.2", 684 | "word-wrap": "~1.2.3" 685 | } 686 | }, 687 | "parse5": { 688 | "version": "1.5.1", 689 | "resolved": "https://registry.npmjs.org/parse5/-/parse5-1.5.1.tgz", 690 | "integrity": "sha1-m387DeMr543CQBsXVzzK8Pb1nZQ=", 691 | "dev": true 692 | }, 693 | "path-is-absolute": { 694 | "version": "1.0.1", 695 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 696 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 697 | "dev": true 698 | }, 699 | "pathval": { 700 | "version": "1.1.0", 701 | "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", 702 | "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", 703 | "dev": true 704 | }, 705 | "performance-now": { 706 | "version": "2.1.0", 707 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", 708 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", 709 | "dev": true 710 | }, 711 | "prelude-ls": { 712 | "version": "1.1.2", 713 | "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", 714 | "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", 715 | "dev": true 716 | }, 717 | "psl": { 718 | "version": "1.7.0", 719 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz", 720 | "integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==", 721 | "dev": true 722 | }, 723 | "punycode": { 724 | "version": "2.1.1", 725 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 726 | "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", 727 | "dev": true 728 | }, 729 | "qs": { 730 | "version": "6.5.2", 731 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 732 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", 733 | "dev": true 734 | }, 735 | "request": { 736 | "version": "2.88.0", 737 | "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", 738 | "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", 739 | "dev": true, 740 | "requires": { 741 | "aws-sign2": "~0.7.0", 742 | "aws4": "^1.8.0", 743 | "caseless": "~0.12.0", 744 | "combined-stream": "~1.0.6", 745 | "extend": "~3.0.2", 746 | "forever-agent": "~0.6.1", 747 | "form-data": "~2.3.2", 748 | "har-validator": "~5.1.0", 749 | "http-signature": "~1.2.0", 750 | "is-typedarray": "~1.0.0", 751 | "isstream": "~0.1.2", 752 | "json-stringify-safe": "~5.0.1", 753 | "mime-types": "~2.1.19", 754 | "oauth-sign": "~0.9.0", 755 | "performance-now": "^2.1.0", 756 | "qs": "~6.5.2", 757 | "safe-buffer": "^5.1.2", 758 | "tough-cookie": "~2.4.3", 759 | "tunnel-agent": "^0.6.0", 760 | "uuid": "^3.3.2" 761 | }, 762 | "dependencies": { 763 | "punycode": { 764 | "version": "1.4.1", 765 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 766 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", 767 | "dev": true 768 | }, 769 | "tough-cookie": { 770 | "version": "2.4.3", 771 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", 772 | "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", 773 | "dev": true, 774 | "requires": { 775 | "psl": "^1.1.24", 776 | "punycode": "^1.4.1" 777 | } 778 | } 779 | } 780 | }, 781 | "safe-buffer": { 782 | "version": "5.2.0", 783 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz", 784 | "integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==", 785 | "dev": true 786 | }, 787 | "safer-buffer": { 788 | "version": "2.1.2", 789 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 790 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", 791 | "dev": true 792 | }, 793 | "sax": { 794 | "version": "1.2.4", 795 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", 796 | "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==", 797 | "dev": true 798 | }, 799 | "source-map": { 800 | "version": "0.6.1", 801 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 802 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 803 | "dev": true, 804 | "optional": true 805 | }, 806 | "sshpk": { 807 | "version": "1.16.1", 808 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", 809 | "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", 810 | "dev": true, 811 | "requires": { 812 | "asn1": "~0.2.3", 813 | "assert-plus": "^1.0.0", 814 | "bcrypt-pbkdf": "^1.0.0", 815 | "dashdash": "^1.12.0", 816 | "ecc-jsbn": "~0.1.1", 817 | "getpass": "^0.1.1", 818 | "jsbn": "~0.1.0", 819 | "safer-buffer": "^2.0.2", 820 | "tweetnacl": "~0.14.0" 821 | } 822 | }, 823 | "supports-color": { 824 | "version": "5.4.0", 825 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", 826 | "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", 827 | "dev": true, 828 | "requires": { 829 | "has-flag": "^3.0.0" 830 | } 831 | }, 832 | "symbol-tree": { 833 | "version": "3.2.4", 834 | "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", 835 | "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", 836 | "dev": true 837 | }, 838 | "tough-cookie": { 839 | "version": "2.5.0", 840 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", 841 | "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", 842 | "dev": true, 843 | "requires": { 844 | "psl": "^1.1.28", 845 | "punycode": "^2.1.1" 846 | } 847 | }, 848 | "tr46": { 849 | "version": "0.0.3", 850 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 851 | "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", 852 | "dev": true 853 | }, 854 | "tunnel-agent": { 855 | "version": "0.6.0", 856 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 857 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 858 | "dev": true, 859 | "requires": { 860 | "safe-buffer": "^5.0.1" 861 | } 862 | }, 863 | "tweetnacl": { 864 | "version": "0.14.5", 865 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 866 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", 867 | "dev": true 868 | }, 869 | "type-check": { 870 | "version": "0.3.2", 871 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", 872 | "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", 873 | "dev": true, 874 | "requires": { 875 | "prelude-ls": "~1.1.2" 876 | } 877 | }, 878 | "type-detect": { 879 | "version": "4.0.8", 880 | "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", 881 | "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", 882 | "dev": true 883 | }, 884 | "uri-js": { 885 | "version": "4.2.2", 886 | "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", 887 | "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", 888 | "dev": true, 889 | "requires": { 890 | "punycode": "^2.1.0" 891 | } 892 | }, 893 | "uuid": { 894 | "version": "3.4.0", 895 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", 896 | "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", 897 | "dev": true 898 | }, 899 | "verror": { 900 | "version": "1.10.0", 901 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", 902 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", 903 | "dev": true, 904 | "requires": { 905 | "assert-plus": "^1.0.0", 906 | "core-util-is": "1.0.2", 907 | "extsprintf": "^1.2.0" 908 | } 909 | }, 910 | "webidl-conversions": { 911 | "version": "4.0.2", 912 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", 913 | "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", 914 | "dev": true 915 | }, 916 | "whatwg-encoding": { 917 | "version": "1.0.5", 918 | "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", 919 | "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", 920 | "dev": true, 921 | "requires": { 922 | "iconv-lite": "0.4.24" 923 | } 924 | }, 925 | "whatwg-url": { 926 | "version": "4.8.0", 927 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-4.8.0.tgz", 928 | "integrity": "sha1-0pgaqRSMHgCkHFphMRZqtGg7vMA=", 929 | "dev": true, 930 | "requires": { 931 | "tr46": "~0.0.3", 932 | "webidl-conversions": "^3.0.0" 933 | }, 934 | "dependencies": { 935 | "webidl-conversions": { 936 | "version": "3.0.1", 937 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 938 | "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", 939 | "dev": true 940 | } 941 | } 942 | }, 943 | "word-wrap": { 944 | "version": "1.2.3", 945 | "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", 946 | "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", 947 | "dev": true 948 | }, 949 | "wrappy": { 950 | "version": "1.0.2", 951 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 952 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 953 | "dev": true 954 | }, 955 | "xml-name-validator": { 956 | "version": "2.0.1", 957 | "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-2.0.1.tgz", 958 | "integrity": "sha1-TYuPHszTQZqjYgYb7O9RXh5VljU=", 959 | "dev": true 960 | } 961 | } 962 | } 963 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript-intro-to-looping", 3 | "version": "0.1.0", 4 | "description": "Introduction to loops in JavaScript on Learn", 5 | "main": "loops.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "mocha -R mocha-multi --reporter-options spec=-,json=.results.json" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/learn-co-curriculum/javascript-intro-to-looping.git" 15 | }, 16 | "keywords": [ 17 | "javascript", 18 | "for", 19 | "while", 20 | "loop", 21 | "learn", 22 | "flatiron" 23 | ], 24 | "author": "", 25 | "license": "SEE LICENSE IN LICENSE.md", 26 | "bugs": { 27 | "url": "https://github.com/learn-co-curriculum/javascript-intro-to-looping/issues" 28 | }, 29 | "homepage": "https://github.com/learn-co-curriculum/javascript-intro-to-looping#readme", 30 | "devDependencies": { 31 | "chai": "^4.1.2", 32 | "chai-spies": "^0.7.1", 33 | "jsdom": "^9.0.0", 34 | "mocha": "^5.2.0", 35 | "mocha-jsdom": "~1.1.0", 36 | "mocha-multi": "^1.0.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/loops-test.js: -------------------------------------------------------------------------------- 1 | /*global describe, it*/ 2 | 3 | const chai = require('chai') 4 | const fs = require('fs') 5 | const jsdom = require('mocha-jsdom') 6 | const path = require('path') 7 | const spies = require('chai-spies') 8 | 9 | chai.use(spies) 10 | 11 | const expect = chai.expect 12 | 13 | function makeArray() { 14 | const array = [] 15 | const t = 10 16 | 17 | for (let i = 0; i < t; i++) { 18 | array.push("I am a strange loop.") 19 | } 20 | 21 | return [array, t] 22 | } 23 | 24 | describe('loops', () => { 25 | jsdom({ 26 | src: fs.readFileSync(path.resolve(__dirname, '..', 'loops.js'), 'utf-8') 27 | }) 28 | 29 | describe('forLoop(array)', () => { 30 | it('adds `"I am ${i} strange loop${i === 0 ? \'\' : \'s\'}."` to an array 25 times', () => { 31 | const [array, t] = makeArray() 32 | const strangeArray = forLoop(array) 33 | const testArray = strangeArray.slice(array.length) 34 | 35 | let first = "I am 1 strange loop." 36 | let rest = "I am 24 strange loops." 37 | 38 | expect(strangeArray[11]).to.equal(first) 39 | expect(strangeArray[34]).to.equal(rest) 40 | expect(strangeArray.length).to.equal(t + 25) 41 | }) 42 | }) 43 | 44 | describe('whileLoop(n)', () => { 45 | it('counts down from n to 0', () => { 46 | const spy = chai.spy.on(console, 'log') 47 | const n = Math.floor(Math.random() * 100) 48 | 49 | expect(whileLoop(n)).to.equal('done') 50 | expect(spy).to.have.been.called.exactly(n) 51 | 52 | console.log.reset() 53 | }) 54 | }) 55 | 56 | describe('doWhileLoop(num)', () => { 57 | it ('console logs "I run once regardless." 1 time when passed an integer of 0 as a parameter.', () => { 58 | const spy = chai.spy.on(console, 'log'); 59 | doWhileLoop(0); 60 | expect(spy).to.have.been.called.exactly(1); 61 | }) 62 | 63 | it ('console logs "I run once regardless." 10 times when passed an integer of 10 as a parameter.', () => { 64 | const spy = chai.spy.on(console, 'log'); 65 | doWhileLoop(10); 66 | expect(spy).to.have.been.called.exactly(10); 67 | }) 68 | }) 69 | }) 70 | --------------------------------------------------------------------------------