Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to make all elements of array uppercase using javascript Array prototype

// how to make all elements of array uppercase using javascript Array prototype
Array.prototype.myUcase = function() {
  for (let i = 0; i < this.length; i++) {
    this[i] = this[i].toUpperCase();
  }
};

const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.myUcase();
console.log(fruits); // [ 'BANANA', 'ORANGE', 'APPLE', 'MANGO' ]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #elements #array #uppercase #javascript #Array #prototype
ADD COMMENT
Topic
Name
2+1 =