/javascriptmas

All my solutions for Scrimba's 2020 Javascriptmas challenges

Primary LanguageHTML

javascriptmas

All my solutions for Scrimba's 2020 Javascriptmas challenges

  1. Candies - n children have got m pieces of candy. They want to eat as much candy as they can, but each child must eat exactly the same amount of candy as any other child. Determine how many pieces of candy will be eaten by all the children together. Individual pieces of candy cannot be split.

  2. Deposit Profit - You have deposited a specific amount of dollars into your bank account. Each year your balance increases at the same growth rate. Find out how long it would take for your balance to pass a specific threshold with the assumption that you don't make any additional deposits.

  3. Chunky Monkey - Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.

  4. Century from year - Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.

  5. Reverse a string - Reverse the provided string. You may need to turn the string into an array before you can reverse it. Your result must be a string.

  6. Sort by length - Given an array of strings, sort them in the order of increasing lengths. If two strings have the same length, their relative order must be the same as in the initial array.

  7. Count Vowel Consonant - You are given a string s that consists of only lowercase English letters. If vowels ('a', 'e', 'i', 'o', and 'u') are given a value of 1 and consonants are given a value of 2, return the sum of all of the letters in the input string.

  8. The Rolling Dice - In this challenge a casino has asked you to make an online dice that works just like it would in real life. Using the pre-made dice face that represents ‘one’, make the faces for ‘two’, ‘three’, ‘four’, ‘five’ and ‘six’. Now when the users clicks the dice on the screen the dice is expected to show one of the faces randomly. Live version here

  9. Sum Odd Fibonacci Numbers - Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num. The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbers of the Fibonacci sequence are 1, 1, 2, 3, 5, and 8. For example sumFibs(10) should return 10 because all odd Fibonacci numbers less than or equal to 10 are 1, 1, 3, and 5.

  10. Adjacent Elements Product - Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.

  11. Avoid Obstacles - You are given an array of integers representing coordinates of obstacles situated on a straight line. Assume that you are jumping from the point with coordinate 0 to the right. You are allowed only to make jumps of the same length represented by some integer. Find the minimum length of the jump enough to avoid all the obstacles.

  12. Valid Time - Check if the given string is a correct time representation of the 24-hour clock.

  13. Extract Each Kth - Given an array of integers, remove each kth element from it.

  14. Maximal Adjacent Difference - Give an arrays of integers, find the maximal absolute difference between any two of its adjacent elements.

  15. Carousel - Use JS to make a carousel with 5 pictures function. Left and right arrows should work. Live version here. Live version here

  16. Insert Dashes - Given a string, insert dashes between the letters and exclude spaces. Live version here

  17. Different Symbols Naive - Return the count of unique characters in a string.

  18. Array Previous Less - Given an array of integers, for each position i, search among the previous positions for the last (from the left) position that contains a smaller value. Store that value at position i in the answer. If no such value can be found, store -1 instead.

  19. Alphabet Sequence - Check whether the given string is a subsequence of the plaintext alphabet.

  20. Domain Type - GoDaddy makes a lot of different top-level domains available to its customers. A top-level domain is one that goes directly after the last dot ('.') in the domain name, for example .com in example.com. To help the users choose from available domains, GoDaddy is introducing a new feature that shows the type of the chosen top-level domain. You have to implement this feature. To begin with, you want to write a function that labels the domains as "commercial", "organization", "network" or "information" for .com, .org, .net or .info respectively. For the given list of domains return the list of their labels.

  21. Sum of Two - You have two integer arrays, a and b, and an integer target value v. Determine whether there is a pair of numbers, where one number is taken from a and the other from b, that can be added together to get a sum of v. Return true if such a pair exists, otherwise return false.

  22. Extract Matrix Column - Given a rectangular matrix and an integer column, return an array containing the elements of the columnth column of the given matrix (the leftmost column in the 0th one).

  23. Tweet Input Component - We are making a Social Media Character Counter! We want to display the available characters LEFT. Using the Keydown event should help you here. When the characters reach 20 and below, we want them to turn red. So we will use Javascript to add that styling to it. If the characters drop below 0, we want the button to be disabled BUT if there are only 0 characters left, we should still be able to tweet. Live version here

  24. Test Your Agility - A game to test how fast you can press a button and get the right number. Live version here