Scrimba's #JavaScriptmas

Scrimba's #JavaScriptmas

24 days, 24 JavaScript challenges.

I've been learning JavaScript for nearly 4 months now. It's not been a straight succes story and there's weeks I didn't do any JavaScript-coding. I'd somehow gone from actively solving daily challenges on Edabit to not doing any at all. The #JavaScriptmas is a great incentive for me to start again. I'm a newbie, which shows in my code. I google a lot. And test a variety of approaches to see which/when I understand (what happens). Sometimes, I use JavaScript Visualizer to help me visualize it. I'm learning new methods and principles that until recently where just a bunch of letters in code I didn't know what they'd do.

Concepts and methods I learned in this series of challenges are a.o.: forEach, include(), set().size, for of, for in, sleep() and Math.abs().

Anyways, here's my 24 solutions to the 24 challenges.

Day 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.

Day 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 you don't make any additional deposits.

Day 3 - Chunky Monkey
Write a function that splits an array(1st argument) into groups the length of size (2nd argument) and returns them as a two-dimensional array

Day 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...

Day 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.

Day 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.

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

Day 8 - Rolling Dice

Day 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.

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

Day 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 minimal length of the jump to avoid all the obstacles.
I didn't quite understand this excercise.

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

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

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

Day 15 - JavaScript Carousel

  • Use JS to make it function
  • Left & right arrows should work
  • Bonus: Use CSS transitions

Day 16 - Insert Dashes
Transform a given sentence into a new one with dashes between each two consecutive letters.
Example: For input="aba caba", the output should be "a-b-a c-a-b-a".

Day 17 - Different Symbols Naive
Given a string, find the numbers of different characters in it.
Example: For s = "cabca", the output should be 3. There are 3 different characters: a, b and c.

Day 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.

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

Day 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. To help the users choose from available domains, GoDaddy is introducing a new feature that shows the type of 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.

Day 21 - Sum of 2
You have two integer arrays, a and b, and an integer value of 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.

Day 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 is the 0th one).

Day 23 - Social Media Input

Day 24 - Test Your Agility