Advertisement
sanjiisan

Untitled

May 14th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. String.prototype.upperLower = function () {
  2. var result = '',
  3. direction = 'up';
  4.  
  5. for (var i = 0; i < this.length; i++) {
  6. if (direction == 'up') {
  7. result += this[i].toUpperCase();
  8. } else {
  9. result += this[i].toLowerCase();
  10. }
  11.  
  12. if (this[i] !== ' ') {
  13. if (direction == 'up') {
  14. direction = 'down';
  15. } else {
  16. direction = 'up';
  17. }
  18. }
  19. }
  20.  
  21. return result;
  22. };
  23.  
  24.  
  25. console.log('ala ma kota i lubi placki'.upperLower());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement