Last active
January 19, 2021 07:50
-
-
Save 0rbianta/5ab42015bc79dbb0a009ffedd7444e76 to your computer and use it in GitHub Desktop.
Find the most repetitive letter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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