+ 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!
2 Antworten
+ 4
this was my solution in freecodecamp ☺ https://code.sololearn.com/W3M5tVUHu6ii/?ref=app
+ 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