We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
javascriptfunctiondesignerPdfViewer(h,word){// Write your code here// data setup for character(s) and height(s)constletters=[];for(letindex=97;index<123;index++){letters.push({char:String.fromCharCode(index),height:h[index-97],});}// find heightletheightArray=[];for(letindex=0;index<word.length;index++){constelement=word.toLowerCase()[index];// index 0 = a , 1 = b, 2 = cconstfindHeight=letters.find((letter)=>letter.char===element);heightArray.push(findHeight.height);}// calculateconstmaxHeight=heightArray.sort((a,b)=>b-a)[0];returnmaxHeight*word.length;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Designer PDF Viewer
You are viewing a single comment's thread. Return to all comments →
js solution