/**
 * @template T
 * @param {T[]} array
 * @param {T} victim
 * @param {T} replacement
 * @returns {T[]} input array after replacements
 */
export function array_replace_all(array, victim, replacement) {

    const n = array.length;
    for (let i = 0; i < n; i++) {
        const el = array[i];

        if (el === victim) {
            array[i] = replacement;
        }
    }

    return array;
}
