Caesar Cipher [The Odin Project-Javascript Exercise]
Welcome to Code Review, some considerations that can help you to simplify your code:


you have an alphabet of 26 letters, so if the shifting operation is
limited to a 26 characters range you can use the mod operation %26
to determine the final position.
you can have a shift negative operation num (ex. -5), for a 26
set of elements shift this is equal to a positive shift of  Math.abs(26 - Math.abs(num)) , so for 5 the positive shift is 21.


So if you have a c character and you want to obtain the ascii code of the corresponding shifted char of num positions you can obtain it in the following way:

const start = c === c.toLowerCase() ? 'a'.charCodeAt(0) : 'A'.charCodeAt(0);
const diff = c.charCodeAt(0) - start;
const sh = num &gt;= 0 ? diff + num : diff + Math.abs(26 - Math.abs(num));
const code = sh % 26 + start;


The first line returns the ascii code of 'a' or 'A' depending if the char c is lowercase or uppercase called start, the second gives you the difference between c and start, the last two lines calculate the code of the shifted corresponding character.

After your function can be rewritten in the following way:

'use strict';

function caesar(str, num) {
    const arr = [];
    const re = /[a-zA-Z]/;
    for (const c of str) {
        if (re.test(c)) {
            const start = c === c.toLowerCase() ? 'a'.charCodeAt(0) : 'A'.charCodeAt(0);
            const diff = c.charCodeAt(0) - start;
            const sh = num &gt;= 0 ? diff + num : diff + Math.abs(26 - Math.abs(num));
            const code = sh % 26 + start;
            arr.push(String.fromCharCode(code));
        } else { 
            arr.push(c); 
        }
    }

    return arr.join('');
}


I set arr and regex as const and instead of iterate over string using the index, I preferred the for ... of construct.

Note: I'm a javascript beginner too, so every suggestion to improve my code as for the original question is highly appreciated.