id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

Warmup 1HasOdds

prev  |  next  |  chance
public static String[] hasOdds(int[] vals) {

    String[] results = new String[vals.length];

    for (int i = 0; i < vals.length; i++)
        if (vals[i] % 2 == 0)
            results[i] = "no";
        else
            results[i] = "yes";

    return results;
}
Function Call  Return Value
hasOdds(new int[]{5, 4, 5})
hasOdds(new int[]{4, 6, 8})
hasOdds(new int[]{5, 7})
hasOdds(new int[]{1, 2, 3, 4, 5})
hasOdds(new int[]{7, 6, 5, 4, 3})
hasOdds(new int[]{1})

Experiment with this code on Gitpod.io

⬅ Back