How to Recreate an Array with new values

Asked

Viewed 71 times

2

How do I take an array in Jquery that has for example 3 numeric values and recreate it with 3 new values?

  • Present the context better. And, show the code you are trying to execute, so it is easier to understand your problem and answer clearly.

  • The question is not clear, which logic for 3 new values?

1 answer

3


Using the function map(). No need to use jQuery for this.

Take an example, there is one array with three items and a new array with the square of these items.

const array = [2, 3, 4];

const quadrados = array.map((item) => item * item);

console.log(quadrados);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.