scrimba
Note at 0:03
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:03
AboutCommentsNotes
Note at 0:03
Expand for more info
main.js
run
preview
console
function differentSymbolsNaive(str) {
// write code here.
let countedCharacters = [];
const characters = str.split("");
characters.map((character) => {
countedCharacters.includes(character)? false: countedCharacters.push(character);
});
return countedCharacters.length;
}



/**
* Test Suite
*/
describe('differentSymbolsNaive()', () => {
it('returns count of unique characters', () => {
// arrange
const str = 'cabca';

// act
const result = differentSymbolsNaive(str);

// log
console.log("result: ", result);

// assert
expect(result).toBe(3);
});
it('returns count of empty string', () => {
// arrange
const str = '';

// act
const result = differentSymbolsNaive(str);

// log
console.log("result: ", result);

// assert
expect(result).toBe(0);
});
it('returns count of non standard characters mixed with numbers', () => {
// arrange
const str = '"4£$"2<';

// act
const result = differentSymbolsNaive(str);

// log
console.log("result: ", result);

// assert
expect(result).toBe(6);
});
});
Console
"result: "
,
6
,
"result: "
,
0
,
"result: "
,
3
,
/index.html
LIVE