Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Latest commit

History

History
156 lines (133 loc) 路 3.99 KB

CHALLENGES.md

File metadata and controls

156 lines (133 loc) 路 3.99 KB

Challenges

Below all the available challenges and some relative examples.

  • 1. ROUND NUMBER

    • NAME: round
    • DESCRIPTION: Write a function that round a number to given decimal places.
     	round(Math.PI, 2); // => 3.14 
  • 2. MERGE MULTIPLE ARRAYS

    • NAME: arrayMerge
    • DESCRIPTION: Write a function that merges multiple given arrays.
     	arrayMerge([1, 2], [3, 4]); // => [1, 2, 3, 4]
  • 3. SUM CONTENT OF AN ARRAY

    • NAME: arraySum
    • DESCRIPTION: Write a function to sum the content of an array.
     	arraySum([1, 2, 3]) // => 6
  • 4. 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'
  • 5. STRING REVERSE

    • NAME: reverseString
    • DESCRIPTION: Write a function that reverse a string.
     	reverseString('hello world!') //=> '!dlrow olleh'
  • 6. CHECK PALINDROME

    • NAME: isPalindrome
    • DESCRIPTION: Write a function that checks if a word is a palindrome.
     	isPalindrome('level') //=> true
     	isPalindrome('racecar') //=> true
  • 7. IS MULTIPLE

    • NAME: isMultipleOf
    • DESCRIPTION: Write a function that checks if a number is multiple of another number.
     	isMultipleOf(15, 3) //=> true
     	isMultipleOf(15, 5) //=> true
  • 8. GET THE LONGEST WORD

    • NAME: longestWord
    • DESCRIPTION: Write a function that returns the longest word of a sentence.
     	longestWord('Hello beautiful people!') //=> 'beautiful'
     	longestWord('aaaa bbb cc d eeee') //=> 'aaaa'
  • 9. CAPITALIZE

    • NAME: capitalize
    • DESCRIPTION: Write a function that capitalize each word in a sentence.
     	capitalize('hello world') //=> 'Hello World'
  • 10. VOWEL COUNT

    • NAME: vowelCount
    • DESCRIPTION: Write a function that count vowel in a sentence.
     	vowelCount('hello') //=> 2
  • 11. MAX CHAR

    • NAME: maxChar
    • DESCRIPTION: Get the most used char in a sentence.
     	maxChar('hello world') //=> {count: 3, char: 'l'}
  • 12. FIZZ BUZZ

    • NAME: fizzBuzz
    • DESCRIPTION: Fizz Buzz game, generate number from 0 to 100 and if the number is multiple of 3 print "Fizz", if mutliple of 5 print "Buzz", if is multiple of both print "FizzBuzz" else print the number.
     	fizzBuzz();
    
     	//=> 1 
     	//=> 2
     	//=> fizz 
     	//=> 4 
     	//=> buzz
     	//=> fizz
     	//=> 7
     	//=> 8
     	//=> fizz
     	//=> buzz
  • 13. SIMPLE ADDING

    • NAME: simpleAdding
    • DESCRIPTION: Write a function that sums all numbers from 0 to the given number.
     	simpleAdding(3) //=> 6
  • 14. ARRAY TO TREE

    • NAME: arrayToTree
    • DESCRIPTION: Transform an array into a tree like object.
     	arrayToTree(['folder', 'subfolder', 'file.txt']) //=> [{name: 'folder', children: [ { name: 'subfolder', children: [ {name: 'file.txt'} ]} ]}]
  • 15. ALPHABETICALLY SORT

    • NAME: alphabeticallySort
    • DESCRIPTION: Write a function that can be used into an Array.sort() for sorting items alphabetically.
     	var myArray = ['Italy', 'Canada', 'Germany'];
     	var mySortedArray = myArray.sort(alphabeticallySort) //=> ['Canada', 'Germany', 'Italy']
  • 16. FIRST RECURRING CHARACTER

    • NAME: firstRecurringChar
    • DESCRIPTION: Write a function that returns the furst recurring character in a string.
     	firstRecurringChar('abacyb') //=> 'a'
  • 17. OBJECT MERGE

    • NAME: objectMerge
    • DESCRIPTION: Write a function that returns an object that includes all given objects.
     	/* Example usage */
     	const user = [
     		{ first: 'john' },
     		{ last:  'doe' }
     	];
    
     	objectMerge({ first: 'john' }, { last: 'doe' });
     	/* OR */
     	objectMerge(user);