This is what is understand from your question and try to solve your issue.

const arr = [1441,1468,1445,1512,1621,1000];

let finalAnswer = [];


for(let i = 1;i<arr.length;i++)
{
  finalAnswer.push(arr[i-1] - arr[i]);
}

console.log(finalAnswer);

Answer from Ferin Patel on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Remainder
Remainder (%) - JavaScript | MDN
When both operands are non-zero and finite, the remainder r is calculated as r := n - d * q where q is the integer such that r has the same sign as the dividend n while being as close to 0 as possible.
🌐
W3Schools
w3schools.com › jsref › jsref_oper_remainder.asp
JavaScript Remainder Operator
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST ... Array[ ] Array( ) at() concat() constructor copyWithin() entries() every() fill() filter() find() findIndex() findLast() findLastIndex() flat() flatMap() forEach() from() includes() indexOf() isArray() join() keys() lastIndexOf() length map() of() pop() prototype push() reduce() reduceRight() rest (...) reverse() shift() slice() some() sort() splice() spread (...) toReversed() toSorted() toSpliced() toString() unshift() values() valueOf() with() JS Boolean
🌐
W3Schools
w3schools.com › js › js_arithmetic.asp
JavaScript Arithmetic
The modulus operator (%) returns the division remainder.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-remainder-operator
JavaScript Remainder(%) Operator - GeeksforGeeks
July 23, 2025 - The remainder operator in JavaScript is used to get the remaining value when an operand is divided by another operand. In some languages, % is considered modulo.
🌐
Rip Tutorial
riptutorial.com › remainder / modulus (%)
JavaScript Tutorial => Remainder / Modulus (%)
This operator returns the remainder left over when one operand is divided by a second operand.
🌐
Josh W. Comeau
joshwcomeau.com › javascript › modulo-operator
Understanding the JavaScript Modulo Operator • Josh W. Comeau
It's guaranteed to always cycle within the range of available indexes for that array. To understand why this works, it's worth remembering our new model for division: we're trying to divide timeElapsed into 3 equally-sized groups, without any fractional or decimal values. The remainder will always be either 0, 1, or 2.
Find elsewhere
🌐
Medium
medium.com › @stitans28 › javascript-remainder-operator-101-794f4df28c87
JavaScript Remainder Operator 101 | by Shawn Townsend | Medium
August 4, 2022 - JavaScript uses the % symbol to represent the remainder operator (also known as the modulo/modulus operator). The remainder operator works by dividing a value by another and when it isn’t evenly distributed the modulus operator returns the ...
🌐
Medium
medium.com › @seanmcp › js-basics-remainder-modulo-bed750a000b
JS Basics: Remainder / Modulo. When you were first learning division… | by Sean McPherson | Medium
October 17, 2017 - 3 % 2 equals 1 remainder 1, and so the return is 1. ... If a number is divisible by two, then x % 2 will equal 0. With that in mind, we can write a function that iterates through an array and uses a modulo to check if each number is even.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-program-to-find-remainder-of-array-multiplication-divided-by-n
JavaScript Program to Find Remainder of Array Multiplication Divided ...
July 23, 2025 - In JavaScript, the remainder of the array multiplication when divided by the number n can be found by iteration, functional programming or array reduction.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › math › quotient and remainder of division
Calculate the quotient and remainder of a division in JavaScript - 30 seconds of code
December 28, 2023 - For example, divmod(8, 3) returns ... in JavaScript, we can use the built-in Math.floor() function to get the quotient and the modulo operator (%) to get the remainder of the division x / y....
🌐
LogRocket
blog.logrocket.com › home › mastering the modulo operator in javascript: a complete guide
Mastering the modulo operator in JavaScript: A complete guide - LogRocket Blog
June 4, 2024 - For example, when we divide 10 by three, we get a quotient of three and a remainder of one. We can also write this as 1 (mod 3). In JavaScript, the modulo operator gets the remainder of a division operation.
🌐
Codedamn
codedamn.com › news › javascript
JavaScript Modulo Operator Guide With Examples
June 3, 2023 - Here are some common use cases ... (floating-point) numbers as well. For example: ... A: The modulo operator (%) returns the remainder of a division operation, while the division operator (/) returns the quotie...
🌐
GeeksforGeeks
geeksforgeeks.org › find-quotient-and-remainder-by-dividing-an-integer-in-javascript
Find quotient and remainder by dividing an integer in JavaScript | GeeksforGeeks
In this article, we are given two or more numbers/array of numbers and the task is to find the GCD of the given numbers/array elements in JavaScript.
Published   June 2, 2023
🌐
Programmingsoup
programmingsoup.com › javascript-remainder-operator
JavaScript: Remainder (%) Operator
The remainder (%) operator returns the remainder of a division. To refresh our memory, a division looks like this, Dividend / Divisor = Quotient.
Top answer
1 of 2
1

Based on your constraints, which are:

  • Single loop variable
  • No restarting of iteration over large arrays

You could calculate your looping step sizes first, then go over the array only once.

  const mushedArr = [];
  const remainderSize = arr.length % size
  const numberOfChunks = Math.floor(arr.length / size);
  let remainderStepSize = Math.floor(remainderSize / numberOfChunks);

I'm going to define the remainder with negative index slicing, so there has to be a guard against calculating a remainder even when division is exact.

let remainder = remainderSize ? arr.slice(-remainderSize) : []

Second edge case is where the remainder is smaller than the chunk size, which would cause my step size to evaluate to 0 and not loop through the remainder properly.

if(remainderStepSize === 0) remainderStepSize ++;

Finally, loop over the array and the remainder:

 let i = 0;
  while(i < numberOfChunks){
    let remainderPortion = remainder
        .slice(i*remainderStepSize, i*remainderStepSize+remainderStepSize);

    let arrayPortion = arr.slice(i*size, i*size+size);

    mushedArr.push([...arrayPortion, ...remainderPortion]);
    i++;
  };
  return mushedArr;
};

Variable names here could be shorter, and the slice can be simplified to something like arr.slice(size*i, size*(i+1), but the idea is to loop over the array and copy the items in sizes that are equal to the chunk size.

Testing for both inputs in your question yielded:

Calling function with input: [A,B,C,D,E,F,G,H,I,J,K,L,M,N]
 chunk size: 5
[ [ 'A', 'B', 'C', 'D', 'E', 'K', 'L' ],
  [ 'F', 'G', 'H', 'I', 'J', 'M', 'N' ] ]
Calling function with input: [A,B,C,D,E,F,G,H]
 chunk size: 3
[ [ 'A', 'B', 'C', 'G' ], [ 'D', 'E', 'F', 'H' ] ]
2 of 2
1

For solution

(a) - just accept a shorter array at the end

code can be very short

function mushInLittleArray(arr, size) {
  let resultArr = [];
  for (let i = 0; i < (arr.length / size); i++ ) {
    resultArr.push( arr.slice( i * size, (i+1) * size ) );
  }
  return resultArr;
}