A growing collection of my solutions to several simple JavaScript exercises.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
99 Bottles
Fizz Buzz
Grade Average Calculator
Ten Simple JavaScript Exercises



This repository is a growing collection of my solutions to simple JavaScript exercises.

Exercise Inspirations

Ten Simple JavaScript Exercises

  1. Define a function max() that takes two numbers as arguments and returns the largest of them. Use the if-then-else construct available in Javascript.
  2. Define a function maxOfThree() that takes three numbers as arguments and returns the largest of them.
  3. Write a function that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise.
  4. Write a function translate() that will translate a text into "rövarspråket". That is, double every consonant and place an occurrence of "o" in between. For example, translate("this is fun") should return the string "tothohisos isos fofunon".
  5. Define a function sum() and a function multiply() that sums and multiplies (respectively) all the numbers in an array of numbers. For example, sum([1,2,3,4]) should return 10, and multiply([1,2,3,4]) should return 24.
  6. Define a function reverse() that computes the reversal of a string. For example, reverse("jag testar") should return the string "ratset gaj".
  7. Write a function to sort a list of words (an array) in alphabetical order
  8. Write a function findLongestWord() that takes an array of words and returns the length of the longest one.
  9. Write a function filterLongWords() that takes an array of words and an integer i and returns the array of words that are longer than i.
  10. Write a function charFreq() that takes a string and builds a frequency listing of the characters contained in it. Represent the frequency listing as a Javascript object. Try it with something like charFreq("abbabcbdbabdbdbabababcbcbab").

See The Code Run

I've created a JSFiddle to demonstrate how each exercise runs: