Escape the 4th Floor

×

* This function numberOfPrimes(n), takes in a number, `12` and returns
the number of prime numbers less than or equal to `12`.
* The answer to this challenge will be used to solve the final question.

function isPrime?(num) {
    if ( num < 2 ) return false;
    for ( let i = 2; i < num; i++ ) {
       if ( num % i === 0 ) return false;
    }
    return true;
}

function numberOfPrimes(12) {
    let numPrimes = 0;
    for ( let i = 2; i <= n; i++ ) {
       if ( isPrime?(i) ) numPrimes += 1;
    }
    return numPrimes;
}

×

* This function first_letters(string), takes in the phrase, "prime members" and
return the first letter of each word.
* The answer to this challenge will be used to solve the final question.

def first_letters(string)
    new_string = [ ]
    words = string.split(" ")
    words.each do |word|
        new_string << word[0]
    end

    return new_string.join("")
end

first_letters("prime members")

Timer

LinkedIn

GitHub

AngelList