You are viewing a single comment's thread. Return to all comments →
javascript solution
function processData(input) { //Enter your code here const phnbookarr = input.split("\n") const totalphnnum = parseInt(phnbookarr[0]) const map = new Map() for (let i = 1; i <=totalphnnum; i++) { const [name, num] = phnbookarr[i].split(" ") map.set(name, num) } for (let i = totalphnnum + 1; i < phnbookarr.length; i++) { const name = phnbookarr[i] if (map.has(name)) { console.log(`${name}=${map.get(name)}`) } else { console.log("Not found") } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
javascript solution