Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.upperLower = function () {
- var result = '',
- direction = 'up';
- for (var i = 0; i < this.length; i++) {
- if (direction == 'up') {
- result += this[i].toUpperCase();
- } else {
- result += this[i].toLowerCase();
- }
- if (this[i] !== ' ') {
- if (direction == 'up') {
- direction = 'down';
- } else {
- direction = 'up';
- }
- }
- }
- return result;
- };
- console.log('ala ma kota i lubi placki'.upperLower());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement