Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

array string to length number

// Solution #1 <---------------->
function stringLengths(str1, str2, str3, str4)
{    
    return [...arguments].map(x => x.length);
}

console.log(stringLengths("hello", "cruel", "world", "of", "darkness"));

// Solution #2 <----------> BEST SOLUTION
function stringLengths(...strings){
    return strings.map(string => string.length);
  }
  console.log(stringLengths("","something","something else"))

Comment

PREVIOUS NEXT
Code Example
Javascript :: how to create dynamic radio button in jquery 
Javascript :: How to Use the Return Keyword in a Function 
Javascript :: Using JSON As Parameter 
Javascript :: How to switch to a remote git branch that does not exist locally 
Javascript :: Function Returning Object Saved To A Variable 
Javascript :: weakset use cases javaScript 
Javascript :: wind in mongoose 
Javascript :: check if a text field is empty javascript 
Javascript :: remove all elements contained in another array 
Javascript :: Passing arrays to functions with the spread operator 
Javascript :: Prototype Constructor Will Be Class or Function 
Javascript :: Using strings, the spread operator creates an array with each char in the string 
Javascript :: How to Add Main Module API to Renderer process 
Javascript :: Changing Prototype 
Javascript :: how to cut and paste an element in vanilla javascript 
Javascript :: check if a specific user is banned discord js 
Javascript :: vertical lineal star pattern javascript 
Javascript :: save input local storage react 
Javascript :: what is container in angular 
Javascript :: google apps script parse html 
Javascript :: execute only once on multiple clicks javascript 
Javascript :: starting: intent error type 3 react-native 
Javascript :: how to square number in javascript 
Javascript :: phaser matter is undefined 
Javascript :: express-roteamento 
Javascript :: react: render dynamic component from json 
Javascript :: nodejs mysql set query timeout 
Javascript :: onclick switch javascript 
Javascript :: class angular dynamic template 
Javascript :: hide navbar and footer on certain pages like dashboard. react-router 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =