function testAmount(sentence, letters) { return letters.map(letter => sentence.match(RegExp(letter, 'g')).length); }
function testAmount(sentence,letters){var a=[];for(var i=0;i<letters.length;i++){a.push(0);for(var j=0;j<sentence.length;j++){if(sentence[j] == letters[i]){a[i]++;}}}return a;- function testAmount(sentence, letters) {
- return letters.map(letter => sentence.match(RegExp(letter, 'g')).length);
- }
describe("Should return how many of a certain letter is in a sentence", function(){ it("should test for the amount of letters in the given letters", function(){ Test.assertEquals(testAmount("a long sentence of random things about the sentences",["a","o"]), [3, 4]); }); });
- describe("Should return how many of a certain letter is in a sentence", function(){
- it("should test for the amount of letters in the given letters", function(){
Test.assertEquals(testAmount("a long sentence of random things about the sentences",["a","o"]), [3,4]);- Test.assertEquals(testAmount("a long sentence of random things about the sentences",["a","o"]), [3, 4]);
- });
- });