Counting Valleys - HackerRank Challenge
You're vastly overcomplicating the solution by introducing three arrays heightTracker, planeTracker, and newArray.  None of those is needed: just track the elevation (which is a better name than height), and go by the definition:


  A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level.


So, the number of valleys traversed is the number of times Gary's elevation changes from -1 to 0.

function countingValleys(n, s) {
    let elevation = 0;
    let traversedValleys = 0;
    for (let i = 0; i &lt; n; i++) {
        if (s[i] === "D") {
            --elevation;
        } else if (s[i] === "U") {
            if (++elevation === 0) traversedValleys++;
        }
    }
    return traversedValleys;
}