Skip to main content

All Questions

1 vote
2 answers
150 views

How to detect whether each element of a list of element-nodes does feature a specific css-class name?

Given the following test environment ... const nodeList = document.querySelectorAll('p'); const testArray = Array.from(nodeList); testArray.every(function (elmNode) { if (elmNode.classList....
Виталий Юрко's user avatar
0 votes
2 answers
97 views

How to check whether an array contains multiple values of a string of whitespace separated values?

Using an Angular application which inserts 'ng-star-inserted' to every node element. I need to check if the target element class exists inside array var footerElementClassList = [ 'footer-...
Surya R Praveen's user avatar
2 votes
2 answers
170 views

Is there a way to search an array of arrays for matching properties and if they match, make sure they aren't in adjacent positions?

I have been wracking my brain for a week on this problem and would appreciate any help or suggestions. I have a form that collects the users first name, last name and song. It stores those values in ...
Steven Wimer's user avatar
1 vote
1 answer
153 views

How do I conditionally deep merge objects in JavaScript with multiple keys

The project I am working on is a trilingual dictionary. I have a database of words, and each word contains (among other things) an array of spelling variations and an array of objects representing ...
micahlt's user avatar
  • 424
0 votes
4 answers
121 views

Create an array using item from different array

I need to create a new array of objects with 12 item (months & value) on it but it must check if the month exist on other array. If it exist it will push onto the array if not it will have a value ...
Monmon's user avatar
  • 39
1 vote
2 answers
75 views

Most efficient way to sort an object based on value with a special rule

I have a situation where I want to create an array based on values (numbers) in an object like so. However, the catch is that if there is ever multiple keys with the same value, then I want the ...
random_narwhal's user avatar
3 votes
8 answers
238 views

How to iterate the sequence of pulling array items from middle (eg:[0,1,2,3,4,5,6,7] -> 4 3 5 2 6 1 7 0) without generating the sequence number array?

For example, when pulling items from the middle of the array : [0,1,2,3,4,5,6,7] (length is 8) const arr=[0,1,2,3,4,5,6,7]; while(arr.length>0){ document.write(arr.splice(arr.length/2,1)+" ");...
wcminipgasker2023's user avatar
0 votes
0 answers
41 views

Binary search comprehension problem. how can a '<' / '>' symbol be checking for strings?

My code works OK. The problem here is comprehension. I get that it splits and goes back and forward in the search. What I don't get is how to give a descriptive explanation on what each code line is ...
Jose Salduna's user avatar
3 votes
1 answer
141 views

Js Equal Distribution Algorithm of Users in Groups

That given n users with v value divide the users into g groups, so that the value of the sum of the values of the users of each group is similar, the number of users per group must be equal to the ...
Paul's user avatar
  • 4,512
1 vote
2 answers
93 views

Initialize a two-dimensional array with the values shown in the table below

Initialize a two-dimensional array with the values shown in the table below 1 0 0 0 1 0 0 0 1 0 0 4 0 0 0 4 0 0 0 4 0 0 9 0 0 0 9 0 0 0 0 0 0 ...
Dennis-The14th-Web's user avatar
0 votes
2 answers
62 views

cartesian combinations for component variants

Let's say I have an object specifying inputs for a button component, and the possible values of that input. const buttonVariants = { colorMode: ['on-dark','on-light'], size: ['small','medium','...
JonesCode's user avatar
3 votes
3 answers
129 views

Based on a condition, how to remove an item from the processed array and move it to another array?

I have two arrays in my react component as follows ... const [Selected, setSelected] = React.useState([]); const [NonSelected, setNonSelected] = React.useState([]); const Tmp_Selected = [ { "...
SM079's user avatar
  • 783
0 votes
0 answers
67 views

Seeking help for the time analysis of a potential optimization of merge sort

Wrote this potentially more optimized version of merge sort. The code can be found here: https://github.com/AntonM-248/CodingInterviewPractice/blob/main/IK_Coursework/SortingAlgorithms/mergeAcross.js. ...
user13204465's user avatar
8 votes
3 answers
585 views

Longest Repeating Subarray (With Overlapping)

Given an array of arbitrary numbers, I am looking to quickly [with time and space complexity lower than O(n²) at minimum, n = length of array] find the longest subarray (a contiguous segment of ...
user23274861's user avatar
-2 votes
1 answer
67 views

My random number sorting algorithm doesnt work

I'm creating this algorithm which is supposed to include numbers 1,2,3,4,5 in an equation which looks like this: @ + ## + ∗ ∗ ∗ + &&&& + $$$$$ The symbols meaning that it could be any ...
Yeetus's user avatar
  • 9

15 30 50 per page
1
2 3 4 5
90