Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Monkey Typing solucionado! :) solution in Clear category for [old] Monkey Typing by coria.luis
"use strict";
function countWords(text, words){
var lenT, lenW, cant = undefined;
lenT = text.length;
lenW = words.length;
cant = 0;
text = text.toLowerCase();
for (var i = 0; i < lenW; i++) {
if (text.indexOf(words[i]) != -1) {
//console.log(words[i] + ' está en el texto.');
cant = cant + 1;
}
}
//console.log(lenT, lenW);
return cant;
}
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!");
}
July 26, 2017