string to binary
Create a method to accept one arbitrary string as an argument, and return a string of length 26 with each character being a number equaling the count of a letter in the alphabet.
by dshilkret
JavaScript
function change(inputString) {
var alphabet = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
inputString = inputString.toLowerCase();
//console.log(inputString);
for(var i=0; i<inputString.length; i++){
//console.log(inputString.charCodeAt(i)-97);
alphabet[inputString.charCodeAt(i)-97]++;
}
return alphabet.join("");
}
console.log(change("a **& bZ"));
var value = [54,68,69,73,20,69,73,20,61,20,64,6,63,75,6,65,6,74,20,62,65,69,6,67,20,75,73,65,64,20,74,6,20,68,65,6,70,20,44,61,76,69, 64,20,26,20,46,61,6,20,73,6,6,76,65,20,61,20,70,72,6,62,6,65,6, 21];
change(value);