scrimba
Note at 0:26
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:26
AboutCommentsNotes
Note at 0:26
Expand for more info
main.js
run
preview
console
function isLetter(inputText) {
const regex = /^[A-Za-z]+$/
return regex.test(inputText)
}

function insertDashes(arr) {
let newString = ""

for (let i=0; i < arr.length; i++) {
// console.log(i + " " + arr[i] + " " + arr[i+1])
newString = newString + arr[i]
if (i < arr.length - 1 &&
isLetter(arr[i]) &&
isLetter(arr[i+1])) {
newString = newString + "-"
}
}
return newString
}

/**
* 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");
});
});
Console
"result: "
,
"a-b-a c-a-b-a"
,
/index.html
LIVE