+ 1

Challenge: camelCase to spinal-tap-case.

convert a camel case string "thisIsAString" to spinal tap case "this-is-a-string". hints... RegExp String.prototype.replace() happy coding!

26th Sep 2017, 7:52 PM
djorborn
djorborn - avatar
3 Answers
+ 4
this was my solution in freecodecamp â˜ș https://code.sololearn.com/W3M5tVUHu6ii/?ref=app
27th Sep 2017, 12:15 AM
ysraelcon
ysraelcon - avatar
+ 3
String.prototype.spinalTap = function() { return this.split('').reduce((r,v,i,a)=>r += (v===v.toUpperCase())? "-" + v.toLowerCase():v); } var test1="thisIsAString"; test1.spinalTap(); https://code.sololearn.com/WRJOBU7iOx4a/?ref=app
27th Sep 2017, 6:32 AM
CalviŐČ
CalviŐČ - avatar