Iggy of Pop of hip hop Iggy of Pop of hip hop - 11 months ago 51
Javascript Question

How do i replace something in array using jquery?

I have got this jquery array

var left=[1,2,3,4];

And i want to replace
element with


You need to use map function here. Try this:

var left = [1,2,3,4];

result = left.map(function(item) { 
    return item == 3? 7: item;