Convert Salesforce 15 Character ID to 18 Character ID Using Javascript

function Convert15CharTo18CharId(id) {
    if (id == null) {
        return id;
    }
    //Scrub quotes from this id
    id = id.replace(/\"/g, '');
    if (id.length != 15) {
        return null;
    }
    var suffix = "";

    for (var i = 0; i < 3; i++) {
        var flags = 0;
        for (var j = 0; j < 5; j++) {
            var c = id.charAt(i * 5 + j);
            if (c >= 'A' && c < = 'Z') {
                flags += 1 << j;
            }
        }
        if (flags <= 25) {
            suffix += "ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(flags);
        } else {
            suffix += "012345".charAt(flags - 26);
        }
    }
    return id + suffix;
}