Give me a native (no jQuery, Prototype, etc. please) JavaScript function that converts numbers as follows:
input: 0.39, 2.5, 4.25, 5.5, 6.75, 7.75, 8.5 outpu
You can use the toFixed() method on Number objects:
var array = [0.39, 2.5, 4.25, 5.5, 6.75, 7.75, 8.5], new_array = []; for(var i = 0, j = array.length; i < j; i++) { if(typeof array[i] !== 'number') continue; new_array.push(array[i].toFixed(2)); }