Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

string reduction javascript

let str = "hello";
// reduce string to the sum of the ascii codes of its characters
str.split().reduce((a,b) => a + b.charCodeAt(0), 0);
Comment

string reduction javascript

// method to extend String to call reduce the same way as an Array
String.prototype.reduce = function () { 
    return this.split().reduce(...arguments);
}

// sum of the ascii codes using the newly created String prototype method
str.reduce((a,b) => a + b.charCodeAt(0), 0);
Comment

PREVIOUS NEXT
Code Example
Javascript :: document getelementsbyclassname not getting all elements 
Javascript :: datatable after render event 
Javascript :: fetch in js 
Javascript :: html print div 
Javascript :: How i can use “LIKE” operator in mongoose 
Javascript :: check data in formData 
Javascript :: react native center text vertically full screen 
Javascript :: nextauth dynamic redirect after login 
Javascript :: node json stringify 
Javascript :: jquery alert on href click 
Javascript :: js rect collision 
Javascript :: can we use two versions of jquery in same page 
Javascript :: js input validate excel file type 
Javascript :: switch browser to fullscreen 
Javascript :: javascript scp in to array 
Javascript :: terminal text length nodejs 
Javascript :: set storage react 
Javascript :: js change div content 
Javascript :: jquery to set value in select2 dropdown button 
Javascript :: nextjs check path in page 
Javascript :: typeof date javascript 
Javascript :: save things javascript 
Javascript :: how to use pass value to the function that was called onchange in react 
Javascript :: demo json data 
Javascript :: click on child prevent click on parent 
Javascript :: nodejs powershell process env 
Javascript :: next js install swr 
Javascript :: adonisjs sync method 
Javascript :: sum the all values from an array 
Javascript :: es6 js slug from string 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =