Explanation

543.Classify Numbers with an isEven Function

Easy
Given an array nums, return a list of the same length with the label "even" or "odd" for each number. Checking one number's parity is covered in the Conditionals section; here the focus is on turning that check into a helper functionHelper FunctionA small function that does one focused job for another function, such as isEven(n). that returns a booleanBooleanA value that is either true or false.. Writing the question "is this even?" once and calling it by name keeps the loop short and makes the same check reusable elsewhere.

Example 1:

Input: nums = [4,7,0,-3]

Output: ["even","odd","even","odd"]

Example 2:

Input: nums = [10]

Output: ["even"]

+ 4 hidden test cases run on Submit.

Constraints:

  • ●1 ≤ nums.length ≤ 50
  • ●-1000000 ≤ nums[i] ≤ 1000000

nums =

[4, 7, 0, -3]