const countLetterInSentence = (sentence, letter) => ([...sentence].filter(test => letter === test).length) function countLettersInSentence(sentence, letters){ return letters.map(letter => countLetterInSentence(sentence, letter)) }
function testAmount(sentence, letters){return letters.map(letter =>[...sentence].filter(test => letter === test).length)- const countLetterInSentence = (sentence, letter) => ([...sentence].filter(test => letter === test).length)
- function countLettersInSentence(sentence, letters){
- return letters.map(letter => countLetterInSentence(sentence, letter))
- }
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.assertSimilar( countLettersInSentence("a long sentence of random things about the sentences",["a","o"]), [3, 4] ); Test.assertSimilar( countLettersInSentence("a long sentence of random things about the sentences",["a","k"]), [3, 0] ); }); });
- 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.assertSimilar(
testAmount("a long sentence of random things about the sentences",["a","o"]), [3, 4]- countLettersInSentence("a long sentence of random things about the sentences",["a","o"]), [3, 4]
- );
- Test.assertSimilar(
testAmount("a long sentence of random things about the sentences",["a","k"]), [3, 0]- countLettersInSentence("a long sentence of random things about the sentences",["a","k"]), [3, 0]
- );
- });
- });