scrimba
Note at 2:46
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 2:46
AboutCommentsNotes
Note at 2:46
Expand for more info
main.js
run
preview
console
function differentSymbolsNaive(str) {
// get number of unique "characters"
return (str === null || str === undefined) ? 0 : Array.from(new Set(str.toString().split(""))).length;
}



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

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(3);
});

it('returns count of unique characters', () => {
// arrange
const str = 'c1a21bca'; // string with numbers

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(5);
});

it('returns count of unique characters', () => {
// arrange
const str = 1233; // number

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(3);
});

it('returns count of unique characters', () => {
// arrange
const str = '+'; // 1 character (symbol)

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(1);
});

it('returns count of unique characters', () => {
// arrange
const str = ''; // empty string

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(0);
});

it('returns count of unique characters', () => {
// arrange
const str = null; // null

// act
const result = differentSymbolsNaive(str);

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

// assert
expect(result).toBe(0);
});

it('returns count of unique characters', () => {
// arrange
const str = undefined; // undefined

// act
const result = differentSymbolsNaive(str);

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

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