JS The Easier Parts - Variables, Data Types, and Control Flow

  • Challenge 1

    Replace the blank underscores inside the console logs with the data type (i.e. 'string') you think each value will be. (Leave the quotes)
    Ex.
    var myStr = "hello"
      console.log(typeof myStr === "string") //=> true
  • Challenge 2

    Create a functon buildSentence that takes three words (strings) and adds them together and console.logs the whole sentence (string) complete with capitalization and punctuation.
  • Challenge 3

    Create a function lastLetter that takes a word (string) and console.logs the last character/letter of that word.
    Hint: Remember that each character/letter in a string has an index position that you can access with brackets: []
  • Challenge 4

    Create a function buildGreeting that takes a time (integer) and a name (string) and print a greeting based on the following rules:
    • If time is between 0 (inclusive) and 11 (inclusive): "Good Morning, <name>!
    • If time is between 12 (inclusive) and 16 (inclusive): "Good Afternoon, <name>!
    • If time is between 17 (inclusive) and 23 (inclusive): "Good Evening, <name>!
    • If time is anything else: "That's not a real time, <name>. Maybe you need some sleep!
  • Challenge 5

    indexOf is a function that you can call on a string (string1) and accepts another string (string2) as an argument.
    It searches through string1 from left to right checking each character to see if it can find string2.
    If it finds string2 it returns the index position of the FIRST character that matches string2. If it cannot find string2 it returns negative one: -1.
    Enter the index position you think indexOf will return for each below.
  • Challenge 6

    Create a function letterExists that takes a word (string) and a character (string), and console.logs whether that letter can be found inside that word.
  • Challenge 7

    Create a function isPrime that console.logs a boolean indicating if `number` is prime or not.
  • Challenge 8

    Create a function range that console.logs all numbers between 'start' and 'end' in sequential order.
  • Challenge 9

    Create a function myIndexOf that takes an array and an element and console.logs the index of the element in the array, or -1 if it doesn't exist.
    Assume the `ele` will be a primitive data type (no arrays or objects).
    DO NOT USE THE BUILT-IN `indexOf` METHOD IN YOUR SOLUTION!
  • Challenge 10

    Create a function unique that console.logs an array where all the duplicates of the input array have been removed; in other words, every element remaining is unique.
  • Challenge 11

    Create a function longestWord that that retuns the longest word of a sentence.
    If there are ties, the function should return the later word.
  • Challenge 12

    Create a function disemvowel that takes in a string and returns a string with all vowels removed.
  • Challenge 13

    Create a function divisibleByFivePairSum that takes an array of numbers.
    It should return an array of all the pairs of indices whose sum is a multiple of five.
  • Challenge 14

    Create a function highestScore that takes in an array of student objects as a parameter.

    It should return a string that corresponds to the student with the highest score.

    The string should contain that student's initials concatenated with their id.

    Assume the array contains at least 1 student object and the student with the highest score is unique (there are no ties).
  • Challenge 15

    Create a function leastCommonMultiple that takes two numbers (integers) as input and returns the lowest number which is a multiple of both inputs.
  • Extension 1

    Create a function arrayBuilder that takes in a count object and returns an array filled with the appropriate numbers of elements. The order of the elements in the array does not matter, but repeated elements should be grouped.
  • Extension 2

    Create a function objectBuilder that takes in a number and returns an object whose keys are 0 up to number and the values are that same number multipled by 5.
  • Extension 3

    Create a function secretCipher that takes in an string(sentence) and an object(cipher). Return a string where every character is replaced with its cooresponding value in the cipher. If the character doesn't exist in the cipher, use the original character.
  • Extension 4

    Create a function passingStudents that accepts an array of student objects.
    It should iterate through the list of students and return an array of the names of all the students who have an average grade of at least 70.
Supported Browsers: