Skip to content

Instantly share code, notes, and snippets.

@0rbianta
Last active January 19, 2021 07:50
Show Gist options
  • Save 0rbianta/5ab42015bc79dbb0a009ffedd7444e76 to your computer and use it in GitHub Desktop.
Save 0rbianta/5ab42015bc79dbb0a009ffedd7444e76 to your computer and use it in GitHub Desktop.
Find the most repetitive letter
const value1 = "Hello World!";
var data = [];
for(var i in value1){
if(value1[i]!=" ") data.push(value1[i]);
}
var build = [];
for(var i in data){
var tmp_counter = 0;
for(var i_ in value1){
if(data[i]==value1[i_]) tmp_counter++
}
build.push(tmp_counter);
}
indexes = [];
for(var i in build){
if(build[i]==Math.max.apply(Math, build)) indexes.push(i);
}
var outs = [];
for(i in indexes){
var proc_index = indexes[i];
console.log();
if(!outs.includes(data[proc_index]))outs.push(data[proc_index]);
}
console.log(outs.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment