0

how to do that? i've been trying something like this

    uint[] public numbers = [1, 2, 3];
    uint[] public numbers2;

    function multiplyArray(uint a) public {
        uint b = numbers.length;
        uint counter = 0;
        for (uint i = 1; i <= b; i++)
        {
        numbers2[i] = numbers[i] * a;
        counter++;
        }
    }
1

Replace numbers2[i] = numbers[i] * a; with numbers2.push(numbers[i] * a)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.