js-challenges
js-challenges copied to clipboard
🏆A collection of Javascript coding challenges, from beginner to advanced.
Some javascript challenges from beginner to advanced difficulty.
Index
- What
- Why
-
Challenges
- Round number
- Merge multiple arrays
- Sum content of an array
-
Object
forEach
- String reverse
- More Challenges
- Partecipating
-
Contributing
- Notes
- Related Repos
What?
A collection of Javascript coding challenges, from beginner to advanced. All challenges are taken from the generous web or created by some awesome contributors.
So, Why?
I'm creating this repo because I want to compile as many coding challenges (for free obviously) in one file. I know that there are many websites like codewars or coderbyte but this is different. These websites may not be free and you may need to pay a subscription.
Challenges
Below are a few challenges - you can get the full documentation here.
If you have an idea on how to improve this repo don't be shy, post a PR or open a new ISSUE!
-
ROUND NUMBER
-
NAME:
round
- DESCRIPTION: Write a function that rounds a number to given amount of decimal places.
round(Math.PI, 2); // => 3.14
-
NAME:
-
MERGE MULTIPLE ARRAYS
-
NAME:
arrayMerge
- DESCRIPTION: Write a function that merges multiple given arrays.
arrayMerge([1, 2], [3, 4]); // => [1, 2, 3, 4]
-
NAME:
-
SUM CONTENT OF AN ARRAY
-
NAME:
arraySum
- DESCRIPTION: Write a function to sum the content of an array.
arraySum([1, 2, 3]) // => 6
-
NAME:
-
OBJECT FOREACH
-
NAME:
objectForEach
- DESCRIPTION: Write a forEach function that works with Objects.
var obj = { first_name: 'Elon', last_name: 'Musk' } objectForEach(obj, (key, value) => { console.log(key, value) }) //=> 'first_name', 'Elon' //=> 'last_name', 'Musk'
-
NAME:
-
STRING REVERSE
-
NAME:
reverseString
- DESCRIPTION: Write a function that reverses a string.
reverseString('hello world!') //=> '!dlrow olleh'
-
NAME:
Participating
- Clone this repo
- Install all dependencies via
npm install
. - Fill all challenges in
./src/challenges.js
. - Test them via
npm run test
. - Share the challenge on twitter via
#jschallenges
- Some ideas? Read below the contributing paragraph or open an ISSUE!
Contributing
- Clone this repo.
- Install all dependencies via
npm install
. - Write down your challenge (with solution) in
./src/challenges.js
. - Write a test for your challenge in
./test/_your-challenge.js
. - Import your test in the
test.js
file. - Test your challenge via
npx ava ./test/_your-challenge.js
. - Move your solution to
./src/solutions.js
. - Submit your PR!
Contributing notes
All challenges need to follow this scheme:
(2 spaces between each challenge)
/**
* CHALLEBGE <n>: <CHALLENGE-NAME>
* @name <functionName>
* @description <challenge-description>
* @author <Your Name> <you[at]domain.com>
*
*
* @example Usage:
* functionName(args) //=> output
*
*
* @param {Type} a ...
* @param {Type} b ...
*
* @returns {Type} ...
*/
module.exports.challenge_name = function() {}
If your challenge is taken from forums please link the thread or the stackoverflow question with @see
READ MORE ABOUT JSODC here
Related
- Javascript30 - 30 Day Vanilla JS Challenge
- Javascript Cardio - JavaScript challenges and problems