Explorer
project
boot.js
index.html
index.js
jasmine-html.js
jasmine.css
jasmine.js
main.js
Dependencies
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
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);
});
});