User Tools

Site Tools


java-script:map-method

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
java-script:map-method [2023/08/11 16:14] – ↷ Page moved from java-script:string:map-method to java-script:map-method odeftajava-script:map-method [2023/08/11 16:20] (current) odefta
Line 104: Line 104:
   * This discount is applied to every second product in the array (i.e., the products at index 0, 2, etc.), so the final prices of the 'Laptop' and 'Tablet' are reduced by 40, resulting in the above output.   * This discount is applied to every second product in the array (i.e., the products at index 0, 2, etc.), so the final prices of the 'Laptop' and 'Tablet' are reduced by 40, resulting in the above output.
  
 +===== Example 4 =====
 +
 +Transform an array of objects into an array of strings:
 +
 +<code javascript>
 +const courses = [
 +    { name: 'JavaScript Fundamentals' },
 +    { name: 'Angular CLI Basics' },
 +    { name: 'JavaScript Fundamentals' },
 +    { name: 'JavaScript Fundamentals' },
 +];
 +
 +const coursesAsArray = courses.map(entry => entry.name);
 +console.table(coursesAsArray);
 +</code>
java-script/map-method.1691759641.txt.gz · Last modified: 2023/08/11 16:14 by odefta