Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

MAP METHOD. IMPORTANT

function toUpper(string) {
  return string.toUpperCase();
}

const cats = ['Leopard', 'Serval', 'Jaguar', 'Tiger', 'Caracal', 'Lion'];

const upperCats = cats.map(toUpper);

console.log(upperCats);
// [ "LEOPARD", "SERVAL", "JAGUAR", "TIGER", "CARACAL", "LION" ]

Here we pass a function into cats.map(), and map() calls the function
once for each item in the array, passing in the item. It then adds the
return value from each function call to a new array, and finally returns
the new array. In this case the function we provide converts the item to
uppercase, so the resulting array contains all our cats in uppercase:
Comment

PREVIOUS NEXT
Code Example
Javascript :: Pointing Subdomain To A Next.js Page On Vercel 
Javascript :: web3 returns an object promise instead of number 
Javascript :: laravel , json Why it shows Cannot access offset of type string on string error 
Javascript :: How to lock thread in javascript energy efficient 
Javascript :: javascript How can i do optional function 
Javascript :: filter json array based on multiple arguments including lists 
Javascript :: js num to str 
Javascript :: how to use same component in multiple place with some logic in angularjs 
Javascript :: how to change css of menu when scrolling 
Javascript :: angularjs How to add row after the last row in ng2 smart table 
Javascript :: Popover AngularJs quickly disappearing 
Javascript :: Porting Promise Chaining from AngularJs to VueJs 
Javascript :: AngularJS slick carousel filter by attribute 
Javascript :: want the app to save the passing screen after a user has passed the test even when the app exits in react native 
Javascript :: Page Pre loader not removing 
Javascript :: how to add link during filter and mapping in javascript 
Javascript :: in node.js with express how to remove the query string 
Javascript :: nodejs api find data with id 
Javascript :: FlatList load top 
Javascript :: json array form to list object java 
Javascript :: ENOENT electron 
Javascript :: controllare che ci sia un file in javascript 
Javascript :: javascript code to decide even or odd number in html using visual studio 
Javascript :: change button text dynamically angular 6 
Javascript :: Download A File With Link Using ExpressJS 
Javascript :: JavaScript Using es6(ES2015) Destructuring assignment 
Javascript :: add text to each element in an array javascript 
Javascript :: pass data between router components 
Javascript :: Backbone Notes Miscellaneous 
Javascript :: strictPopulate 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =