Try to give an alternative in this question WITHOUT LOOPING! Just using indexOf and some integer math
Get coordinates of an element in multidimentional array in Javascript
The code below seemed promising but fails.
Anyone with better math skills feel like fixing it?
var letterVariations = [
[' ','0','1','2','3','4','5','6','7','8','9'],
['A','a','B','b','C','c','D','d','E','e',';'],
['Â','â','F','f','G','g','H','h','Ê','ê',':'],
['À','à','I','i','J','j','K','k','È','è','.'],
['L','l','Î','î','M','m','N','n','É','é','?'],
['O','o','Ï','ï','P','p','Q','q','R','r','!'],
['Ô','ô','S','s','T','t','U','u','V','v','“'],
['W','w','X','x','Y','y','Ù','ù','Z','z','”'],
['@','&','#','[','(','/',')',']','+','=','-'],
];
var string = JSON.stringify(letterVariations);
var pos = string.indexOf("u")
console.log(Math.floor((pos/10)%9),pos%10)
// fails, how to fix?
pos = string.indexOf("M")
console.log(Math.floor((pos/10)%9),pos%10)
% 8"?[[" ","0","1","2","3","4","5","6","7","8","9"],["A","a","B","b","C","c","D","d","E","e",";"]..., you can't search here, it's better to useletterVariations.toString()xposition, I think you can try to proportionate the value to the length of the string. Example:uhas index 307, using:Math.floor((pos*11)/string.length)you can get thexposition, which is 8 in that case. It's 11 because it's an 11x9 grid. I'm not sure how you can get the Y value though.