scrimba
Note at 3:27
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 3:27
AboutCommentsNotes
Note at 3:27
Expand for more info
main.js
run
preview
console
function differentSymbolsNaive(str) {
str = (
typeof str === 'string' && str ||
typeof str === 'number' && `${str}` ||
''
);
return new Set([...str]).size;
}



/**
* Test Suite
*/
describe('differentSymbolsNaive()', () => {
it('returns count of unique characters', () => {
// arrange
const str = 'cabca';
const result = differentSymbolsNaive(str);
console.log("result: ", result);
expect(result).toBe(3);
});

it('returns count of unique digits if input is a number', () => {
const num = '112233334';
const result = differentSymbolsNaive(num);
console.log("result: ", result);
expect(result).toBe(4);
});

it('returns 0 if input is null or undefined', () => {
const val = null;
const result = differentSymbolsNaive(val);
console.log("result: ", result);
expect(result).toBe(0);
});

});
Console
"result: "
,
3
,
"result: "
,
4
,
"result: "
,
0
,
/index.html
LIVE