No description, website, or topics provided.
Switch branches/tags
Nothing to show
Latest commit f0671f6 Dec 6, 2017 @flawgical flawgical committed on GitHub Enterprise Update
Failed to load latest commit information. Update Dec 6, 2017



Title: Morning Lab
Creator: Thom Page
Topics: Problem solving with functions

Morning Lab - Problem solving


Write a function called printGreeting with a parameter name that returns a greeting with the argument interpolated into the greeting.


=> Hello there, Slimer!


Write a function reverseWordOrder that accepts a single argument, a string. The function should return a string with the order of the words reversed. Don't worry about punctuation.

console.log(reverseWordOrder("Ishmael me Call"));

=> "Call me Ishmael"

console.log(reverseWordOrder("I use Lâncome on my comb"));

=> "comb my on Lâncome use I"


Write a function called calculate.

This function should take three arguments, two numbers and a string.

Name the parameters num1, num2, and operation.

If the function receives the string "add" for the operation parameter, it will return the sum of num1 and num2.

If the function receives the string "sub" for the operation parameter, it will return num1 minus num2.

Do the same thing for multiplication "mult", division "div", and exponent "exp" (where num2 is the exponent of num1).

console.log(calculate(4, 3, "sub"));

=> 1
console.log(calculate(4, 3, "exp"));

=> 64

pandigital numbers

A number of length n is 1-to-n pandigital if it makes use of all the digits 1 to n exactly once.

  • The number 15234 is 1-to-n pandigital.

  • The number 333 is not 1-to-n pandigital.

  • The number 0 is not 1-to-n pandigital.

  • The number 987654321 is 1-to-n pandigital.

Write a function that checks if a number is 1-to-n pandigital.