diff --git a/lib/assert.js b/lib/assert.js index c3faba09053474..61258deb6b076d 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -868,9 +868,9 @@ assert.ifError = function ifError(err) { tmp2.shift(); // Filter all frames existing in err.stack. let tmp1 = newErr.stack.split('\n'); - for (let i = 0; i < tmp2.length; i++) { + for (const errFrame of tmp2) { // Find the first occurrence of the frame. - const pos = tmp1.indexOf(tmp2[i]); + const pos = tmp1.indexOf(errFrame); if (pos !== -1) { // Only keep new frames. tmp1 = tmp1.slice(0, pos);