Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

map function usage in frontend

let cont = document.getElementById('#container');
  
let users = [
    { firstName : "John", lastName: "Doe", age: 17 },
    { firstName : "Stephen", lastName: "Matt", age: 16 },
    { firstName : "Abigail", lastName: "Susu", age: 15 }
];
  
let singleUser = users.map((user)=>{
    // Let's add the firstname and lastname together
    let fullName = user.firstName + ' ' + user.lastName;
    return `
      <h3 class='name'>${fullName}</h3>
      <p class="age">${user.age}</p>
    `
});
  
container.innerHTML = singleUser;
Comment

PREVIOUS NEXT
Code Example
Javascript :: Use a stack to convert the infix expression x*y-2 into post-fix 
Javascript :: drupal attached js 
Javascript :: prisma multiple queries in one query 
Javascript :: Listen to custom event in Vue js 
Javascript :: TOP Array Methods 
Javascript :: how to prevent screen tearing without vsync 
Javascript :: eva icons js 
Javascript :: javascript get minutes between two dates 
Javascript :: passing third parameter in context.commit vuejs 
Javascript :: javascript get object list by value 
Javascript :: Minimum Path Sum Rec 
Javascript :: cocos creator localstorage 
Javascript :: js Changing selected option by option id, class, or attribute 
Javascript :: react password check wordpress api 
Javascript :: array inside array javascript 
Javascript :: pass function name as string javascript 
Javascript :: convert .js file to ts 
Javascript :: Make a Responsive Portfolio Website: JavaScript and HTML 
Javascript :: random jwt secret key generator 
Javascript :: toggling individual item using map in react 
Javascript :: javascript dom functions 
Javascript :: Plumsail set form lookup field value on form load 
Javascript :: createfileinput javascript 
Javascript :: web3 returns an object promise instead of number 
Javascript :: javascript llop array 
Javascript :: ! function in javascript 
Javascript :: How can I save a option from multi select in Angular 
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 :: Render JOSN in frontend 
Javascript :: Pass 3 of the same thing to ExpressJS with a form 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =