about | help | code help+videos | done | prefs |
Write a method that returns the number of dashes appearing at the start or end of 'str'. Only dashes at the start or end count. Do not count dashes in the middle of the string. If the string is only one character long, and that character is a dash, it only counts once. Look at the test data for examples. The ONLY string methods you are allowed to use for this problem are: .length .equals .substring (both forms) .charAt .toUpperCase .toLowerCase quiz2021_10_21_APSLHL_findDash("-This string starts AND ends with a dash-") → 2 quiz2021_10_21_APSLHL_findDash("No dashes (-) at the start-or the end-but some in the middle") → 0 quiz2021_10_21_APSLHL_findDash("Dashes --- in the middle --- do not count!") → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 220
Copyright Nick Parlante 2017 - privacy