// Q.s : 1
var newReleases = [
{
“id”: 70111470,
“title”: “Die Hard”,
“boxart”: “http://cdn-0.nflximg.com/images/2891/DieHard.jpg”,
“uri”: “http://api.netflix.com/catalog/titles/movies/70111470”,
“rating”: [4.0],
“bookmark”: []
},
{
“id”: 654356453,
“title”: “Bad Boys”,
“boxart”: “http://cdn-0.nflximg.com/images/2891/BadBoys.jpg”,
“uri”: “http://api.netflix.com/catalog/titles/movies/70111470”,
“rating”: [5.0],
“bookmark”: [{ id: 432534, time: 65876586 }]
},
{
“id”: 65432445,
“title”: “The Chamber”,
“boxart”: “http://cdn-0.nflximg.com/images/2891/TheChamber.jpg”,
“uri”: “http://api.netflix.com/catalog/titles/movies/70111470”,
“rating”: [4.0],
“bookmark”: []
},
{
“id”: 675465,
“title”: “Fracture”,
“boxart”: “http://cdn-0.nflximg.com/images/2891/Fracture.jpg”,
“uri”: “http://api.netflix.com/catalog/titles/movies/70111470”,
“rating”: [5.0],
“bookmark”: [{ id: 432534, time: 65876586 }]
}
]
// // 1- read only id and title and push into blank array
// // 2- print bookmark which has a data
// // 3 - print rating if it is greater than 4
class release_data{
constructor(data){
this.data_info=data;
}
id_info(){
var x=this.data_info.map((elem)=>{
return `The id is :- ${elem.id} "The title is :-" ${elem.title}${"<br>"}`
})
// console.log(x)
document.write(x)
}
book_marks(){
this.data_info.map((elem)=>{
var y= elem.bookmark.map((data)=>{
return `"bookmark id is"${data.id} "bookmark time is" ${data.time} <br>`
})
document.write(y)
// console.log(y)
})
}
rating_info(){
this.data_info.map((elem)=>{
var z=elem.rating.filter((el)=>{
return el>4
})
document.write("Rating greater than 4 is "+z+"<br>")
console.log(z)
})
}
}
var new_rel=new release_data(newReleases)
new_rel.id_info()
new_rel.book_marks()
new_rel.rating_info()
output is
The id is :- 70111470 “The title is :-” Die Hard
,The id is :- 654356453 “The title is :-” Bad Boys
,The id is :- 65432445 “The title is :-” The Chamber
,The id is :- 675465 “The title is :-” Fracture
"bookmark id is"432534 “bookmark time is” 65876586
"bookmark id is"432534 “bookmark time is” 65876586
Rating greater than 4 is
Rating greater than 4 is 5
Rating greater than 4 is
Rating greater than 4 is 5
In rating greater than 4 i want to print only two line rating greater than is 5 the remaining two line which not having ant data that does not want to print soo plzz check my code rating_info() how can i print only two line which is only greater than 4 gives me value 5?