function numObj(s){
var emptyObj = {};
s.forEach(function(num) {
emptyObj[num] = String.fromCharCode(num);
});
return emptyObj;
}
console.log(numObj([118,117,120]));
I am writing this function to convert the int to its corresponding char in alphabet. However,
I am expecting as an output {'118': 'v', '117': 'u', '120': 'x' }
, but when I ran the code I get: { '117': 'u', '118': 'v', '120': 'x' }
. Does anyone have any explanation why does the function change the order of the input?