Guide on dividing an array extracted from a JSON result into 2 separate arrays

I'm not a coder, but I'm trying to troubleshoot an app. Can you assist me in solving this riddle?

Below is the array in question:

{[[1525711250000,398],[1525711260000,408],[1525711270000,null], 
[1525711280000,410],[1525711290000,396],[1525711300000,380], 
[1525711310000,372],[1525711320000,366],[1525711330000,355], 
[1525711340000,355],[1525711350000,357],[1525711360000,349], 
[1525711370000,355],[1525711380000,355]]}

Could you enlighten me on how to create 2 new arrays as follows?

new_array1 = {[1525711250000,1525711260000,152571127000,1525711280000,1525711290000....]}

new_array2 = {[398,408,null,410....]}

Thank you very much.

Answer №1

To utilize ES, simply implement the map function on the initial array in the following manner:

arr_1 = elements.map(element => element[0])
arr_2 = elements.map(element => element[1])

In this case, the elements array represents the specified array

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Top method for detecting browser closure or navigation to a different page and initiating a logout

In the development of my GWT application, I am facing the challenge of detecting when a user leaves the application or closes the browser window (onUnload event) and initiating a logout process, which involves invalidating the session and performing certai ...

Storing numerical values from a text file in an array

I need to extract numbers from a file and store them in an array. 3 2 15 41 4 1 2 3 4 3 22 11 24 The first line indicates the number of lines that follow (maximum 100). Each line can contain up to 50 numbers. To store these numbers in an array, it shoul ...

After approximately 1-2 days, a node.js socket.io script is being terminated by SIGSEGV

My node.js server is running using forever, but after 1-2 days my script gets killed and the log file shows this error: error: Forever detected script was killed by signal: SIGSEGV I added console.log statements at the beginning of each function in my no ...

Ascending Order of WordPress Locations

I need help sorting the order of locations in Word Press, where the locations are stored within the posts meta data. On my home page, there is a drop-down box for users to select a location, and I would like them to be ordered from A - Z <?php ...

What is the best way to empty a TextField in a React application?

Greetings to all! I could use some help figuring out how to clear a TextField after clicking the icon. Any suggestions would be greatly appreciated. Thanks! const [filteredLocations, setFilteredLocations] = useState(locations); const clearSearch = () =& ...

I noticed a strange question mark appearing in my URL after submitting the login form

I recently started working with React and I am using Material UI for the login functionality. However, whenever I click on the login button, my URL changes and the input data gets cleared. Before clicking on the Login button, the URL is: http://localhost: ...

What is the correct way to update a value in React context?

In my current setup, I have the ColorContext declared as follows: const ColorContext = React.createContext("") I am attempting to create a basic function that can alter the context value, which will be utilized as a global state variable in various other ...

The click event fails to trigger while trying to parse external HTML

Currently, I am working on a project that requires me to load HTML from an external file and insert it into an existing div element. Although the process is successful overall, I have encountered an issue where the .click() events do not trigger when click ...

Developing a React project that is steadily progressing

My React apps are taking an unusually long time to build when I use the "npm run build" command in the terminal. It's been over 15 minutes each time. Can anyone provide any insight into what might be causing this delay? ...

Problems with form functionality in React component using Material UI

Trying to set up a signup form for a web-app and encountering some issues. Using hooks in a function to render the signup page, which is routed from the login page. Currently, everything works fine when returning HTML directly from the function (signup), ...

Changing the key of a nested item within an array of objects using JavaScript

My task in JavaScript is to change the names of canBook -> quantity, variationsEN -> variations, and nested keys valueEN -> value. var prod = [{ price: 10, canBook: 1 }, { price: 11, canBook: 2, variationsEN: [{ valueE ...

Tips for transferring information from controller JavaScript to view JavaScript within AngularJS

Currently, I am working on an angularJS application where I retrieve data from a REST service within the controller. The retrieved data is then passed to the view using $scope. However, I encountered an issue when trying to use this data in my in-page Java ...

Refreshing a portion of the view following the submission of a post with jQuery AJAX in ASP.NET MVC

I've been developing a form for my application and I'm trying to implement AJAX submission. The data is successfully sent to the controller, but instead of refreshing the entire page, I want to display a success message on the view. Do I need to ...

What could be causing the entire app to malfunction when the Redux Provider tag is used

I am facing an issue while trying to integrate a React Toolkit app into my project. The error message I encountered is as follows: Error: Invalid hook call. Hooks can only be called inside the body of a function component. This error may occur due to one ...

Getting an array of objects following multiple ajax requests

When working on a project, I integrated checkbox filters using ajax. Within my controller, there is an action set up like this: def casinos_filters providers_from_categories = Provider.joins(:categories).where('categories.id = ?', params[:ca ...

Error encountered while attempting to parse the JSON file on a specific line. An "EOF" (end of file) was expected, even

Here is a snippet from my JSON file: {"_id":3,"date_created":"2016-01-01T00:00:00Z","date_updated":"2016-01-01T00:00:00Z","name":"Computers","slug":"Computers","description":"Computers","meta_description":"Computers","meta_keyword":"Computers","navigation ...

Dynamically hiding elements within tabs using jQuery

Previously, I created a functionality for handling a single set of tabs. However, as the application has expanded, this functionality is no longer sufficient to accommodate multiple sets of tabs. The initial function looked like this: var iconTabs = func ...

sending data from Node.js to JavaScript

Attempting to utilize Google's provided sample code from their PhotoFrame repository has proven challenging. The framework consists of node.js, expressjs, jQuery, and more. I am struggling to pass a variable - let's refer to it as myString - from ...

How can I use ngx-editor to insert an HTML block at the current cursor position by clicking a button?

I am currently using ngx-editor within Angular 7. My goal is to insert HTML at the cursor's position upon clicking on parameters from a list. The current view displays how the parameter is appended when clicked, as shown in the image attached https:// ...

"Encountering a 'Cannot GET' error message while utilizing Rest API in Node.js

Currently, I am developing a project using nodejs along with the expressjs framework. My focus right now is on setting up and running a "Rest Api," but I seem to be encountering an error message that reads: Cannot GET /published Let me share my routes fil ...