scrimba
Note at 0:43
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

AboutCommentsNotes
Note at 0:43
Expand for more info
main.js
run
preview
console
function differentSymbolsNaive(str) {
// write code here.
let a =[...str] //converts string to array of string
let b = new Set(a) //converting to set removes duplicate
return b.size //function of set to get size of set
}




/**
* 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 unique number', () => {
// arrange
const str = '2356662';

// act
const result = differentSymbolsNaive(str);

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

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

it('returns count of unique symbols', () => {
// arrange
const str = '$%$$&*';

// act
const result = differentSymbolsNaive(str);

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

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

it('returns count of unique mix of num and letter', () => {
// arrange
const str = '2S4SG';

// act
const result = differentSymbolsNaive(str);

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

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


});
Console
"result: "
,
4
,
/index.html?spec=differentSymbolsNaive()%20returns%20count%20of%20unique%20symbols
LIVE