UPDATE 2016-12-01: Please refer to the official guide instead of this process.
UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.
Hello,
const RomanDictionary = { | |
'1': 'I', | |
'5': 'V', | |
'10': 'X', | |
'50': 'L', | |
'100': 'C', | |
'500': 'D', | |
'1000': 'M', | |
}; |
const RomanDictionary = { | |
'1': 'I', | |
'5': 'V', | |
'10': 'X', | |
'50': 'L', | |
'100': 'C', | |
'500': 'D', | |
'1000': 'M', | |
}; |
function wordCount(str) { | |
if (typeof str !== 'string' || !/\w+/.test(str)) return 'Error: bad input'; | |
var words = str.toLowerCase().match(/(\w+(?<!'\w+)'\w+|\w+)/g); | |
var incrementWordCount = (word_count, word) => { | |
word_count[word] = 1 + (word_count[word] | 0) | |
return word_count; | |
}; |
function wordCount(str) { | |
var words = str.toLowerCase().split(/\W*\s\W*|[^'\w]+/); | |
var incrementWordCount = (word_count, word) => { | |
word_count[word] = 1 + (word_count[word] | 0) | |
return word_count; | |
}; | |
return words.reduce(incrementWordCount, {}); | |
} |
wordCount('word'); | |
// returns { word: 1 } | |
wordCount('one of each') | |
// returns { one: 1, of: 1, each: 1 } | |
wordCount('one fish two fish red fish blue fish'); | |
// returns { one: 1, fish: 4, two: 1, red: 1, blue: 1 } | |
wordCount('all the kings horses and all the kings men'); |
function sumOfMultiples(limit, factors = [3, 5]) { | |
var multiple; | |
var multiples = []; | |
var isValidInt = num => Number.isInteger(num) && num > 0; | |
var validFactors = array => Array.isArray(array) && array.every(isValidInt); | |
var collectFactorsUniqueMultiples = function(factor) { | |
multiple = factor; |
function sumOfMultiples(limit, factors = [3, 5]) { | |
var multiple; | |
var multiples = []; | |
//TODO: Validate inputs | |
var collectFactorsUniqueMultiples = function(factor) { | |
multiple = factor; | |
while (multiple < limit) { |
// Second argument's omitted, default to factors [3, 5] | |
console.log(sumOfMultiples(10)) // returns 23 | |
console.log(sumOfMultiples(100)) // returns 2318 | |
console.log(sumOfMultiples(1000)) // returns 233168 | |
// Limit is smaller than all factors (3, 5) | |
console.log(sumOfMultiples(1)) // returns 0 | |
// Limit is smaller than some factor(s) | |
console.log(sumOfMultiples(4)) // returns 3 |
UPDATE 2016-12-01: Please refer to the official guide instead of this process.
UPDATE 2014-12-21: RubyGems 1.8.30, 2.0.15 and 2.2.3 have been released. It requires manual installation, please see instructions below.
Hello,
<!doctype html> | |
<html lang="en-US"> | |
<head> | |
<title>M. Edgar Joel</title> | |
<meta charset="UTF-8" /> | |
</head> | |
<body> | |
<h1>M. Edgar Joel</h1> | |
https://github.com/mwakipesile | |