common Denominators in an array js
function convertFrac(lst){ let numerator = []; let denominator = []; let allDen; let str = ''; lst.forEach((e,i,arr)=>{ numerator.push(arr[i][0]); denominator.push(arr[i][1]) }) for (let i = 1; i < 1000000; i++) { all = denominator.every(e => i % e == 0) if (all) { allDen = i; break; } } numerator.forEach((e,i)=>str +=`(${(allDen/denominator[i])},${allDen})`) return str; }