Tried googling for a while but couldn’t find my answer. I am trying to take a 3-character string and convert it to a 6-character string in which each of the 3 characters is duplicated. For example, 3ff would become 33ffff. First, I’m turning the string 3ff into the array [“3”, “f…
Tag: arrays
Can I do a binary search on an array of objects?
I am currently learning how to use searching and sorting algorithms and I am running into issues with a binary search on an array of objects of customers’ data. The array of customers is sorted by first and last name. The goal is to find a customer’s email and return the index. The data looks like…
Using a for-loop to retrieve elements from an Array
I’m new to JS and keep running into issues for a recent class assignment. I’ve reached out to my professor for help but I’m still not understanding it. For our assignment, I need to use a for-loop to retrieve elements from my beatlesArray and concatenate them into a string variable with this format if the ima…
How to convert a javascript array of Objects from one format to another format?
I have an array of objects and want to convert it from one format to another format. the initial array looks like: how to convert it to a format like this? any help please? Answer You can populate an objected keyed off the value categories and add the relevant data.
filter value of select to do a partial sum
Having two classes professor and student: professor.ts student.ts To add up the scores of each student relative to his teacher I did: This is the HTML of the page: How can I do a partial sum of the selections, assuming for example that I have 5 professor with 1 student for every professor, and want to add onl…
How to remove duplicates by property of an object in an array of objects and copy all properties of duplicates?
I delete all duplicates by the “sourceType” property of the object in the array of objects, but I cannot copy the “dataType” property from the duplicates to the original, please check what I’ expecting in at output and expected output output: expected output: Answer You need to g…
TypeError when swapping object properties with destructuring assignment [duplicate]
This question already has answers here: ES6 Array destructuring weirdness (4 answers) What are the rules for JavaScript’s automatic semicolon insertion (ASI)? (7 answers) Closed 1 year ago. I am trying to swap two object values in JavaScript using the [] = [] method, but my below code fails with an erro…
Check array for length and push or update the object within
I’m really struggling with my code and cannot find a way to make it work. I need to check whether my array exists or its length is not 0 and then if there is an object with a specific value in it. If so then update it. If not then add it. Please see my code below: Many thanks for
myComponent.map is not a function
I have this information right now that i’m saving and trying to pass to a component who then tries to create Tabs and TabPanel (Material-ui components) with said info. The declaration of that info goes as follow : I then proceed to pass said info to my component: On the other side i have an interface th…
Want to remove previously appended table
When I Click on submit button after clicking on the links it appends perfectly but when I hit the button again it doesn’t remove previously appended table. I want to clear the previously created table when user clicks on the cross button and then print the table again or else overwrite the table but ins…