Quick actions

cmd+k|ctrl+k

Navigation

Languages

highest-scoring

Snippet info

Language

JavaScript

Visibility

public

Author

pallavid

Created

2021-09-17T19:28:13.930446Z

Updated

2021-09-17T20:15:12.80217Z

function high(x){

let arr=x.split(' ')
let sumArr=[]

for(let i=0; i<arr.length; i++){
    let word=arr[i].split('')
    let sum=0
    for(let j=0; j<word.length; j++){
      sum=sum + (word[j].charCodeAt(0)-96)
    }
    sumArr.push(sum)
}
let index = sumArr.indexOf(Math.max(...sumArr))
return arr[index]
}
console.log(high("man i need a taxi up to ubud"))
console.log(high("what time are we climbing up the volcano"))
console.log(high("take me to semynak"))
console.log(high("aa b"))
console.log(high("b aa"))
INFO