score:3
Accepted answer
you only want to use map
once, and retrieve the returned value:
const areas = [
{name: 'haram', condition: true, counter: 5},
{name: 'nasr city', condition: false, counter: 3},
{name: 'faisl', condition: true, counter: 7}
];
const newareas = areas.map(({name}) => ({label: name, value: name}));
console.log(newareas);
this makes use of object destructuring.
Source: stackoverflow.com
Related Query
- Javascript 2 arrays of objects , get a value from one array of objects and assign it to the other array of objects
- How to find if one of the items have completed property with value false from an array of objects using javascript and react?
- How to reduce and get value from object array using javascript
- How to get value based on key from an array of objects javascript
- How to get Current week from given array of objects date in javascript
- Comparing two arrays and filtering one array upon this in javascript and react
- Get the max value for a date from an array of objects
- Get object array from axios and using return value call another axios function and append the output to first result
- How to get array of objects in javascript from an array of dictionaries in python?
- get lat and lng from array of objects on React
- how can i extract arrays from one array & convert them in object and put them in a new array?
- How to take a link from one array and assign it to another?
- How to get values from one array of objects into another array of objects
- How to group arrays of objects by value and add the result to another array with same value at specific key
- How to consecutively add values from one array to another and store the value in a new array in javascript?
- A lookup function to match the same IDs in two different arrays of objects and inserting key/value pairs into one of the array of objects
- How do I iterate over an array of objects match a common element from another array and return the key value for "name"
- Get value from One function and pass it to another
- React yup validation with and react-hook-form, array of different type of objects depends from one of object attribute
- Get the component from array of objects and add new properties to it - React
- Merge two arrays of different objects into one array of objects combined from the first two
- Why does only one of the two objects from array get passed as prop?
- How to get a value in an array that's in a list of arrays in javascript
- Get object property value from array of objects
- How to optimally get one key and value from object consisting of one pair?
- removing empty array objects from an array in javascript and react
- React.js - How to get access to a specific value from an array of objects
- Comparing two arrays of nested objects and return new array of objects if compared values are not the same in javascript
- How do I take an array of objects from state and push a specific value of the objects into a new array
- trying to get id's from array of objects and push those id's into array
More Query from same tag
- Key error when there is already one on Javascript and REACT AXIOS
- Get value from an input in an array on button click ReactJs
- Cannot access data from ActionCable on React front-end
- Dynamically component doesn't work in React
- React protected component's redux state is reset before thunk promise resolves
- Update Set after delete using a checkbox to delete Set Item
- React - FC - How to stop execution in react environment
- Is it Possible to style Table horizontal scrollbar?
- React State value not updated in Arrow functional component
- Integrate SanitizeFunction with React textArea onPaste
- React dev tools show data state, console shows empty
- How can I set background image by dynamic names with styled-component?
- onLoadEnd is not fired in react-native Image
- React + Nodejs : Share code between Front and Back End
- I'm trying to add animation to my web page title using anime.js and jQuery, but it throws an error
- React error on onclick event and function handling
- How can I refactor by moving files in a JavaScript project and have references update automatically?
- ics description ignores everything after #(hash) symbol - ics.js
- React - Changing CSS property on click (arrow function)
- Objects not valid as a React child (found: [object Promise])
- How to trigger a CSS animation on EVERY TIME a react component re-renders
- How to change the background color of react-bootstrap's switch (part of the Forms component) using Emotion
- React Hooks: updating state using useState does not update the state immediately
- Is there a way to perform server side rendering of SVG graphics using React?
- WordPress Gutenberg-Block Editor component SelectControl: custom event prop
- How to do so that my field must at least be able to contain only numbers and a + in front of the number (if the user wishes)
- can I use context API as almost another source of truth in a project that already has Redux?
- Replace array item with another one without mutating state
- How to render seperated JSONs in react that are correlated
- Responsive Layout in React Native iOS