scrimba
Note at 0:28
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:28
by
AboutCommentsNotes
Note at 0:28
by
Expand for more info
main.js
run
preview
console
//option 1 

const insertDashes=(arr)=>arr.split("").join("-").replace('- -', ' ')


// option 2
// const insertDashes=(arr)=> {
// let str1 =arr.split("").join("-")
// return str1.concat(arr.split("-"," ")).replace("- -"," ")
// }




// }
/**
* Test Suite
*/


describe('insertDashes()', () => {
it('insert dashes in between chars', () => {
// arrange
const value = "aba caba";

// act
const result = insertDashes(value);

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

// assert
expect(result).toBe("a-b-a c-a-b-a");
});
it('insert dashes in between chars', () => {
// arrange
const value = "bobo hello";

// act
const result = insertDashes(value);

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

// assert
expect(result).toBe("b-o-b-o h-e-l-l-o");
});
it('insert dashes in between chars', () => {
// arrange
const value = "a";

// act
const result = insertDashes(value);

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

// assert
expect(result).toBe("a");
});
it('insert dashes in between chars', () => {
// arrange
const value = "a b";

// act
const result = insertDashes(value);

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

// assert
expect(result).toBe("a b");
});
});
Console
"result: "
,
"a b"
,
"result: "
,
"a"
,
"result: "
,
"a-b-a c-a-b-a"
,
"result: "
,
"b-o-b-o h-e-l-l-o"
,
/index.html
LIVE