about | help | code help+videos | done | prefs |
jan11_2016_APSLHLnumStringRepeat
Write a method that returns a string constructed of the character 'ltr' and the space character. The string is constructed based on the parameter 'max' which will be a non-negative integer (and not too big!). The 'max' parameter will tell you the maximum number of times 'ltr' will be all in a row. Return a string with 1 copy of 'ltr' followed by a space, then 2 copies of 'ltr' followed by a space, and so on until you have 'max' copies of 'ltr' followed by a space. For example, if 'max' is 3 and 'ltr' is 'X' the string would be "X XX XXX". Look at the test data for further examples. Notice that there IS a space at the end of the string, except in the case where 'max' is zero. In that case, you return an empty string. jan11_2016_APSLHLnumStringRepeat(0, "H") → "" jan11_2016_APSLHLnumStringRepeat(2, "7") → "7 77 " jan11_2016_APSLHLnumStringRepeat(1, "j") → "j " ...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: 280
Copyright Nick Parlante 2017 - privacy