about | help | code help+videos | done | prefs |
onesComplement
Returns the one's complement of the String argument. The one's complement of a binary number is obtained by inverting all the bits, swapping 0s for 1s and vice versa. The argument will only contain 1s and 0s. (Note that your solution need not be recursive, it will be used as a helper function in the next problem) onesComplement("1") → "0" onesComplement("0") → "1" onesComplement("101") → "010" ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy