7 kyu
RuplesJS #3: String EachChar
274 of 646NateBrady23
Description:
Your team is really excited with all the contributions you've made to the RuplesJS library. They feel the work you're doing will truly help Ruby developers transition to Javascript! They've assigned you another task.
String.eachChar()
In ruby you can add something after each character in a string like so:
"hello".each_char {|c| print c, ' ' } -> "h e l l o "
In the spirit of polymorphism, our eachChar method will allow one of two arguments, a callback function or a string. If a string is presented, it will be added after each character of the original string and return the new string. If a function is presented, it will perform a manipulation of each character in the string.
Example:
each_char("hello"," ")
-> "h e l l o "
def func(c):
return 'L' if c=='l' else c
each_char("hello all", func)
-> "heLLo aLL"
Please add your contribution to RuplesJS!
Check out my other RuplesJS katas:
Fundamentals
Language Features
Similar Kata:
Stats:
Created | Dec 28, 2015 |
Published | Dec 28, 2015 |
Warriors Trained | 1311 |
Total Skips | 70 |
Total Code Submissions | 1846 |
Total Times Completed | 646 |
JavaScript Completions | 356 |
Python Completions | 274 |
Ruby Completions | 48 |
Total Stars | 12 |
% of votes with a positive feedback rating | 90% of 169 |
Total "Very Satisfied" Votes | 141 |
Total "Somewhat Satisfied" Votes | 21 |
Total "Not Satisfied" Votes | 7 |