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 alphabetSubsequence(str) {
// write code here.
console.log(str);
const checkForDuplicatesByLength = new Set(str).size !== str.length;
console.log(checkForDuplicatesByLength);
const strSort = str.split('').sort().join('');
console.log(strSort);
return checkForDuplicatesByLength === false && strSort === str;
}



/**
* Test Suite
*/
describe('alphabetSubsequence()', () => {
it('returns false when it has duplicate letters', () => {
// arrange
const str = 'effg';

// act
const result = alphabetSubsequence(str);

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

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

it('returns false when NOT in ascending a - z order', () => {
// arrange
const str = 'cdce';

// act
const result = alphabetSubsequence(str);

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

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

it('returns true whenno duplicates and is ascending a - z order ', () => {
// arrange
const str = 'ace';

// act
const result = alphabetSubsequence(str);

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

// assert
expect(result).toBe(true);
});
});
Console
"effg"
,
true
,
"effg"
,
"result 1: "
,
false
,
"cdce"
,
true
,
"ccde"
,
"result 2: "
,
false
,
"ace"
,
false
,
"ace"
,
"result 3: "
,
true
,
/index.html
LIVE