I’m new to stackoverflow and would appreciate some advice to help me solve this problem. I have two strings that I want to extract numbers from String 1 = “12.3,Name1,3,4,Name2,35,Name3” returns [12.3,3,4,35] Which is the required result. String 2 = “12.3,22,Q” returns [12.322] W…
Tag: arrays
Get a specific object from an array of objects [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 7 months ago. Improve this question Here is the sample input How to get an output that would be like Thank you in advance Answe…
jQuery: push checked checkboxes to array
I am trying to add to array checked checkboxes, but the array comes up empty, what am I doing wrong on my script? Answer Fix
Get every nth element of array with a function of 2 arguments
I’ve been working on some challenges and this is one of the challenges I’ve been unable to get a solution of. This task is like this: Write a function that takes an array (a) and a value (n) as arguments Save every nth element in a new array Return the new array This is the output I’m expect…
Push multiple objects to an already initialized, empty object array
People is my model, data is my new information, and the forEach is how I am trying to insert the new data into my model, but formatted to only the information I care about However, the result I get is this: I’m trying to have the object array look like this instead: However, I would like to know if ther…
Chunk an array of objects and add empty arrays at the end
I need to chunk an array of objects so i write: and it works fine if I have rules like { 0: 2, 1: 2 } but when I have rules at the end like { 0: 2, 1: 2, 2:0, 5:0 } my function ignore to create empty arrays at the end. the output I need is: so I
How to check if an email address is written more than once or not
I am using a map in javascript and using the logic if the number of fields is more than the map size then any of the mail addresses are repeated. The problem arises as the map takes empty and undefined values, thus giving the wrong output. Suppose I keep 1st and 2nd fields empty then undefined is the map, sho…
JavaScript: Comparing Two objects in one array
I’m new to this world of vanilla javascript. I’ve been trying complete some challenges but it seems like I’m unable to find the solution to a challenge. The task is:”Sort array by object property” Write a function that takes an array of objects as an argument Sort the array by pr…
How to create a schema to add several array into object Node/mongo db using post
this is the schema that I have now but I need to add more array as number 2, 3, 4 example: //post api Answer Just try to create a schema with an empty object like: Schema so you can add multiple elements. But your data completely depends on what you are sending in your API request.
How to render only new items in a react list and not re render the whole list
My problem is when I have more than one object in the state every item of the list re-renders and they each have a deletion timeout (I want them to be deleted after an amount of time) which is reset at each re-render. I tried to use React.memo() and React.useCallback() to prevent the item in the list to re-re…