Output: User Ruby watched Transit and Max also watched the same movie and gave rating above 3. So User ruby recommendation has to be Max Jurassic Park and not weekend away userRecommend("Ruby", ratings) => ["Jurassic Park"]
How do i get the ouput for below?
const userRating = [
['David', 'Weekend Away' , 5],
['Shell', 'Frozen', '5'],
['Max', 'Jurassic Park', '5'],
['Ruby', 'Transit', '4'],
['Ruby', 'Inception', '4'],
['Max', 'Transit', '5']
['Max', 'Weekend Away', '1']
]
const userRecommendation = (user, userRating) =>{
const hash = {};
for(let i=0; i< userRating.length; i++){
if(userRating[i][2] >=4){
if(!hash[userRating[i][0]]){
hash[userRating[i][0]] = [userRating[i][1]];
}else {
hash[userRating[i][0]].push(userRating[i][1]);
}
}
}
let userMovie = hash[user];
let result =[];
for(let key of Object.keys(hash)){
// Need to find a way to filter
}
}
console.log(userRecommendation('Ruby', userRating));