DEV Community

Cover image for Monday Express Day [5]
Cliff Gor
Cliff Gor

Posted on

 

Monday Express Day [5]

Hello, welcome to the fifth BigO notation challenge where we will be solving a few challenges.

Goodmorning again welcome to #mondayexpress, today we will be heading over to our exercisim team where each week I share new challenges to fix.

Here is today's challenge

Introduction
Implement the accumulate operation, which, given a collection and an operation to perform on each element of the collection, returns a new collection containing the result of applying that operation to each element of the input collection.

Given the collection of numbers:

1, 2, 3, 4, 5
And the operation:

square a number (x => x * x)
Your code should be able to produce the collection of squares:

1, 4, 9, 16, 25
Check out the test suite to see the expected function signature.

Restrictions
Keep your hands off that collect/map/fmap/whatchamacallit functionality provided by your standard library! Solve this one yourself using other basic tools instead.

Setup
Go through the setup instructions for Javascript to install the necessary dependencies:

https://exercism.io/tracks/javascript/installation

Requirements
Please cd into exercise directory before running all below commands.

Install assignment dependencies:

$ npm install

Making the test suite pass
Execute the tests with:

$ npm test

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by changing xtest to test.

Submitting Solutions
Once you have a solution ready, you can submit it using:

exercism submit accumulate.js
Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

To Join click on the link here Monday Express. If you need more languages covered you can always reach out

Let's Join and solve these challenges.

Top comments (0)

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!