Create a function that takes a string and returns that string with the first half lowercased and the last half uppercased.
Example:
foobar => fooBAR
If the string length is an odd number then 'round' it up to find which letters to uppercase. See example below.
sillycase("brian")
// --^-- midpoint
// bri first half (lower-cased)
// AN second half (upper-cased)
Language: PHP
Length:
81939094Solution
[edit] hah, this is the exact same as @cwhite92's answer above, even down to the variable names!! lmao, gmta. Ok here's a slightly improved version, for 90:
and since both of those are buggy for even-length strings, here's a clean 94:
okay here's a for loop for 121 cheekily using array notation on a string instead of splitting it out...
here's another php version using a bunch of array functions, 116 chars…
(or this bug-free version of that at 120, bugs are just features though right? who codes to a spec anyway…)
…not sure why but I quite like this one, i think because we do the upper bit first and work on half the word at a time rather than each letter. In at 118…