Scoring a Field Goal

Published by Mubashir Hassan in

In (American) Football, a team can score if they manage to kick a ball through the goal (i.e. above the crossbar and between the uprights).

Create a function that returns true if the ball 0 goes through the goal. You will be given an array of strings.

Examples

isGoalScored([
  "  #     #  ",
  "  #  0  #  ",
  "  #     #  ",
  "  #######  ",
  "     #     ",
  "     #     ",
  "     #     "
]) ➞ true

isGoalScored([
  "  #0    #  ",
  "  #     #  ",
  "  #     #  ",
  "  #######  ",
  "     #     ",
  "     #     ",
  "     #     "
]) ➞ true

isGoalScored([
  "  #     #  ",
  "  #     #  ",
  "  #     # 0",
  "  #######  ",
  "     #     ",
  "     #     ",
  "     #     "
]) ➞ false

Notes

  • All goals will be of the same size.
  • All arrays will be of equal length (11).
  • A team can never score if it hits the crossbar or goes underneath it.
Watch a quick demo on how Edabit works.