IQ 51: If string begins with "red" or "blue" return the color

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Difficulty: Easy
    If a string begins with the "red" or "blue" then return that color

Комментарии • 2

  • @khasanganikhodjaev
    @khasanganikhodjaev 7 лет назад

    why did u not use myString.startWith(String) function in first part?

    • @umutnumanoglu1056
      @umutnumanoglu1056 7 лет назад

      Its startsWith, you forget an "s", but I'd also solve it in the same way, there is also no need to check for length as if it's shorter if would also give a false. (I tried it and it worked for me)
      Btw if my understanding is correct the question asked for to "return" the strings red and blue, not print them. I made a public static String function and I returned the strings.