← all problems

firstWord 🌶️

Write a method that takes one String parameter, s, and returns everything in s up to (but not including) the first space. For example, firstWord("hello world") should return "hello". You may assume s always contains at least one space, and does not begin with one.