Q:

Randomize uppercasing / lowercasing on all string characters

Kind of an odd request, I know. But I've been looking for a solution to this for quite a while now. This is the effect I'm looking for:
var myString = "Hello I am randomly capitalized"

Desired function result:
hElLO i aM rAnDOmlY caPiTAlizED

I imagine this is best done with javascript arrays in one way or another. Just looking for some creative ideas. Thank you! 

A:

Here's one way
myString.split('').map(function(c){
    return c[Math.round(Math.random())?'toUpperCase':'toLowerCase']();
}).join('');

You could add this as a prototype method on the string object for easy access if desired:
String.prototype.toRandomCase = function() {
    return this.split('').map(function(c){
        return c[Math.round(Math.random())?'toUpperCase':'toLowerCase']();
    }).join('');
}

Then access by
console.log(myString.toRandomCase());

A bit of an explanation of how this works:

String.split method is used to split the string into an array of individual characters.
Array.map function is used. This takes a callback function that is applied to each item in an array, and returns a new resulting array with each value returned by the map function.
Inside the map function

Math.round(Math.random()) is used for randomness
The result of that is used with a ternary operator to get toLowerCase or toUpperCase
Math.Round(Math.random())?'toLowerCase':'toUpperCase'
The result of the ternary operator is used to access the relevant function property by array deferencing of the character, then called. c[<ternary here>]()

Finally it uses Array.join method on the result of the map function call to join the resulting array back into a string.

Code golf (efficiency)
RobG's answer has a more efficient approach than mine (please upvote his answer)
String.prototype.toRandomCase = function() {
    return this.toLowerCase().split('').map(function(c){
        return Math.random() < .5? c : c.toUpperCase();
    }).join('');
}

If anyone has suggestions for improving this further - please comment or edit this part of the answer

A:

Well, based on Joel's answer…
myString.toLowerCase().split('').map(function(c){
    return Math.random() < .5? c : c.toUpperCase();
}).join('');

