Completed Task 3, isValidWord() function