Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- var movies = [
- {
- title: "Red Sparrow",
- hasWatched: true,
- rating: 6.6
- },
- {
- title: "Wonder",
- hasWatched: true,
- rating: 8
- },
- {
- title: "Wedding Crashers",
- hasWatched: false,
- rating: 7.0
- },
- {
- title: "The Internship",
- hasWatched: true,
- rating: 6.3
- },
- {
- title: "Starsky & Hutch",
- hasWatched: true,
- rating: 6.1
- },
- {
- title: "Meet the Fockers",
- hasWatched: true,
- rating: 6.3
- }
- ]
- rater.prototype.percentage = function(movieRating, scale){
- return (movieRating/scale) * 100;
- }
- var movieTitle = "";
- var theRating = 0.0;
- for (counter = 0; counter < Object.keys(movies).length; counter++){
- movieTitle = movies[counter].title;
- theRating = (movies.percentage(movies[counter].rating,10));
- document.write("<p>");
- document.write("<b>Movie title: </b>" + movieTitle + "<br>");
- document.write("<b>IMDB Rating: </b>" + theRating.toFixed(2) + "<br>");
- document.write("</p>");
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement