Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

return longest string from array

arr.reduce((a, b)=> a.length > b.length ? a : b);
Comment

all longest strings javascript

function solution(inputArray) {
    return inputArray.reduce((r, s, i) => {
        if (!i || r[0].length < s.length) {
            return [s];
        }
        if (r[0].length === s.length) {
            r.push(s);
        }
        return r;
    }, []);
}
Comment

javascript find the longest string in array

Math.max(...(x.map(el => el.length)));
Comment

how to find the longest string in given string using js

function longestWordLength(str) {
  return Math.max(...str.split(' ').map(word => word.length));
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: node require fs not found 
Javascript :: handle onchange react 
Javascript :: javascript add days 
Javascript :: three.js cube 
Javascript :: check a date is between two dates in javascript 
Javascript :: Comparing and Filtering two arrays 
Javascript :: logical operators in js 
Javascript :: js maths 
Javascript :: convert string to camelcase 
Javascript :: why can i put comments in some json files 
Javascript :: read json file into array javascript 
Javascript :: how to enable emit on react in vs code 
Javascript :: javascript slice 
Javascript :: html js how to draw on screen 
Javascript :: javascript select function 
Javascript :: declare multiple variables javascript 
Javascript :: concat strings shopify liquid 
Javascript :: How To Take Screenshots In The Browser Using JavaScript 
Javascript :: jquery attribute 
Javascript :: jspdf 
Javascript :: java script strict tag 
Javascript :: graphql query 
Javascript :: js object entries 
Javascript :: github remote 
Javascript :: html anchor tag javascript confirm 
Javascript :: hackerearth javascript solutions 
Javascript :: page reload detect in jquery 
Javascript :: regex scan youtube video id 
Javascript :: framer motion reactjs 
Javascript :: jquery carousel slide event 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =