File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ function findNaughtyStep ( original , modified ) {
2+
3+ const [ lessWords , mostWords ] =
4+ [ original , modified ] . sort ( ( a , b ) => a . length - b . length )
5+
6+ return [ ...mostWords ] . find ( ( x , i ) => [ ...lessWords ] [ i ] != x ) ?? ""
7+ }
8+
9+ module . exports = findNaughtyStep
Original file line number Diff line number Diff line change 1+ const findNaughtyStep = require ( './main.ts' )
2+
3+ test ( "Test #01 - Returns a String" , ( ) => {
4+ expect (
5+ typeof findNaughtyStep ( 'abcd' , 'abcde' )
6+ ) . toBe ( "string" )
7+ } )
8+
9+ test ( "Test #02 - findNaughtyStep('abcd', 'abcde')" , ( ) => {
10+ expect ( findNaughtyStep ( 'abcd' , 'abcde' ) ) . toStrictEqual ( "e" )
11+ } )
12+
13+ test ( "Test #03 - findNaughtyStep('xxxx', 'xxoxx')" , ( ) => {
14+ expect ( findNaughtyStep ( 'xxxx' , 'xxoxx' ) ) . toStrictEqual ( "o" )
15+ } )
16+
17+ test ( "Test #04 - findNaughtyStep('stepfor', 'stepor')" , ( ) => {
18+ expect ( findNaughtyStep ( 'stepfor' , 'stepor' ) ) . toStrictEqual ( "f" )
19+ } )
20+
21+ test ( "Test #05 - findNaughtyStep('iiiii', 'iiiii')" , ( ) => {
22+ expect ( findNaughtyStep ( 'iiiii' , 'iiiii' ) ) . toStrictEqual ( "" )
23+ } )
You can’t perform that action at this time.
0 commit comments