DEV Community

Cover image for Day 14 of JavaScriptmas - Maximal Adjacent Difference Solution
Sekti Wicaksono
Sekti Wicaksono

Posted on

Day 14 of JavaScriptmas - Maximal Adjacent Difference Solution

Day 14 is finding the highest adjacent difference.

If a given array [2,4,1,0] will has the highest adjacent difference is 3.
If a given array [2,9,1,0] will has the highest adjacent difference is 8

This is JavaScript solution

function arrayMaximalAdjacentDifference(nums) {
    return Math.max(...nums.map((a,b) => Math.abs(a-b)));
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more