Answer to Question #287994 in HTML/JavaScript Web Application for Rushi

Question #287994

Let arr =["string","array","hello",null, undefined];

Find the length of each string But null , undefined length should be return 0

By using array map function


1
Expert's answer
2022-01-16T13:04:18-0500
const arr =["string","array","hello",null, undefined]
const A = arr.map(myFunction)

function myFunction(arr[i]) {
for (let i = 0; i < 4; i++) {
if (arr[i]==null || arr[i]==undefined) {
  A[i]=0;
} else {
  A[i]=arr[i].length;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS