main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function spinalCase(str) {
  var array = str.match(/[A-Z]/g);
  var test = "";
  console.log(array);
  for (var i = 0; i < array.length; i++){
    str = str.replace(/[^a-z]/gi, '');
    console.log(str);
    console.log(array[i]);
    str = str.replace(array[i], "-"+array[i])
    console.log(str);
  }
  return test;
}
spinalCase("TheAndyGriffithSho w");
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie