aksnell / assignments

0 stars 0 forks source link

06 - 02 - Iteration in JavaScript #21

Closed aksnell closed 4 years ago

aksnell commented 4 years ago

Objectives

After completing this assignment, you should be able to:

Instructions

  1. Fork this repository to your own account.
  2. Change into your projects directory:
  3. Clone your repository: hub clone js-iteration
  4. Change into your project's directory: cd js-iteration
  5. Install the dependencies: yarn install (or just yarn for short)
  6. Open in your editor]
  7. Start the test runner: yarn test
  8. Open src/functions.test.js and work on functions until tests pass.
  9. Commit and push your work to GitHub.
  10. Turn in the URL to your GitHub repo.

Explorer Mode

Epic Mode

Additional Resources

Reference the documentation on DevDocs to find what kind of helpful functions might already be in JavaScript.

aksnell commented 4 years ago

https://github.com/aksnell/js-iteration

All tests passing, etc.

I can do the epic mode challenge, but I spent way to long trying to see if I could extend the actual array prototype (I understand why this is a terrible idea to never do for real) and I could not make Object.defineProperty and by then I had to move on to other work.

https://repl.it/@theoriginalaks/IntelligentGeneralDeletion#index.js

I have literally no idea whats wrong, it seems to my tired eyes, identical to every example I can find.

gstark commented 4 years ago

Use string interpolation here: return array.map((str, index) => str + " is at index " + index.toString())

It is something in the repl.it environment.

On my computer:

~ » node
Welcome to Node.js v14.4.0.
Type ".help" for more information.
> Array.prototype.myMap = () => console.log('hello')
[Function (anonymous)]
> [].myMap()
hello

On repl.it

 Array.prototype.myMap = () => console.log('hello')
[Function]
 [].myMap()
TypeError: [].myMap is not a function
    at repl:1:4
    at Script.runInContext (vm.js:131:20)
    at REPLServer.defaultEval (repl.js:433:29)
    at bound (domain.js:426:14)
    at REPLServer.runBound [as eval] (domain.js:439:12)
    at REPLServer.onLine (repl.js:759:10)
    at REPLServer.emit (events.js:310:20)
    at REPLServer.EventEmitter.emit (domain.js:482:12)
    at REPLServer.Interface._onLine (readline.js:322:10)

Perhaps it is the way they are running the code, or a "security" feature.

aksnell commented 4 years ago

Your homework 06 - 02 - Iteration in JavaScript was marked: Meets Expectations

Well done!

“Well done!”