Ask Question
18 March, 06:44

Define a jа vascript function named thanos which has a single parameter. This function will be called so that the parameter will be an array. Your function should return a NEW array which contains only the entries at even indices. (Hint: you can tell an index is even if that index mod 2 is equivalent to 0) ... Examples: thanos ([ ]) would evaluate to [ ] thanos (['0', 2, 4]) would evaluate to ['0', 4]

+4
Answers (1)
  1. 18 March, 08:47
    0
    See explaination

    Explanation:

    function thanos (lst) {

    var result = [];

    for (var i = 0; i < lst. length; i + = 2) {

    result. push (lst[i]);

    }

    return result;

    }

    / / Testing the function here. ignore/remove the code below if not required

    console. log (thanos ([]));

    console. log (thanos (['0', 2, 4]));
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Define a jа vascript function named thanos which has a single parameter. This function will be called so that the parameter will be ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers