Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to reverse a string in JavaScript using reduce function

const reverseString = (str) => {
    return str.split('').reduce((acc, currItem)=> currItem + acc, '');//acc is accumulator
};

reverseString('hello world!');
// => !dlrow olleh
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove empty option from bootstrap select javascript 
Javascript :: react testing for links 
Javascript :: js encryption 
Javascript :: vue js tutorial 
Javascript :: link reload page react 
Javascript :: largest and smallest number in an array 1-100 javascript 
Javascript :: base64 nodejs image 
Javascript :: how check if a form date is before today javascript 
Javascript :: reverse javascript 
Javascript :: check if number is float 
Javascript :: how to get type of variable in javascript 
Javascript :: javascripti remove int character from string 
Javascript :: first letter uppercase in jquery 
Javascript :: javascript object instead of switch 
Javascript :: delete all the fields on the form whit jquery 
Javascript :: axios get image 
Javascript :: react router dom change default path 
Javascript :: regex for a, e, i , o , u 
Javascript :: react-hook-form file validation 
Javascript :: next day date javascript 
Javascript :: regex street 
Javascript :: document cookies javascript 
Javascript :: array put value in index 
Javascript :: next-auth with linkedin provider 
Javascript :: js for 
Javascript :: array join 
Javascript :: reload datatable without ajax 
Javascript :: reflect javascript 
Javascript :: express js delete request 
Javascript :: mongoose search in multiple fields 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =