Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Monkey Typing by Sim0000
"use strict";
function countWords(text, words){
text = text.toLowerCase();
let count = 0;
for(let word of words){
if(text.includes(word)) count++;
}
return count;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(countWords("How aresjfhdskfhskd you?", ["how", "are", "you", "hello"]), 3, "Example");
assert.equal(countWords("Bananas, give me bananas!!!", ["banana", "bananas"]), 2, "BANANAS!");
assert.equal(countWords("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", ["sum", "hamlet", "infinity", "anything"]), 1, "Weird text");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
May 15, 2017
Comments: