The function to adds a value to the first index of an array

    /**
     * This function adds a value to the first index of an array.
     * @param {Array} arr - The array to which the value will be added.
     * @param {*} value - The value to add to the array.
     * @returns {Array} The modified array with the value added to the first index.
     */
    const addToFirstIndex = (arr, value) => {
        arr.unshift(value);
        return arr;
    }

Leave a comment

Your email address will not be published. Required fields are marked *