Ask Question

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]

+3
Answers (1)
  1. 25 March, 01:57
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers