← Back to challenges

Skip the Drinks with Too Much Sugar

JavaScriptHardarrayslanguage_fundamentals

Instructions

Write a function that takes an array of drinks and returns an array of only drinks with no sugar in them. Drinks that contain sugar (in this challenge) are:

  • cola
  • fanta

Examples

skipTooMuchSugarDrinks(["fanta", "cola", "water"]) ➞ ["water"]

skipTooMuchSugarDrinks(["fanta", "cola"]) ➞ []

skipTooMuchSugarDrinks(["lemonade", "beer", "water"]) ➞ ["lemonade", "beer", "water"]

Notes

  • The function returns an array of strings.
  • All drink names are in lowercase.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Add the Index