Iggy of Pop of hip hop Iggy of Pop of hip hop - 8 months ago 30
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;