AIDS Meanstack Dev: Lab4 5a
Create an array of objects having movie details. The object should include the movie name, starring, language, and ratings. Render the details of movies on the page using the array.
<html>
<body>
<h1>Movie Details</h1>
<script>
function Movie() {
let movies = [
{
"name":"Sir",
"starring":["dhanush", "xyz", "saikumar"],
"language":"telugu",
"rating": 4.0
},
{
"name":"Thegimpu",
"starring":["Ajith", "xyza", "saikumar11"],
"language":"tamil",
"rating": 4.2
}
]
movies.forEach(movie => {
alert(movie['name']);
alert("starring"+movie['starring']);
alert(movie['language']);
alert("rating"+movie['rating']);
});
/* var and let are both used for variable declaration in javascript but the difference between them is that var is function scoped and let is block scoped. Variable declared by let cannot be redeclared and must be declared before use whereas variables declared with var keyword are hoisted.*/
let name = "Swamy Vivekananda";
let starring = `Benarji
Sita
Rajesh
Dhawan`;
let language = "telugu";
let ratings = 4.0;
let details=`Movie:${name},rating:${ratings}`
let det2=`language:${language},starring:\n${starring}`;
alert(details+det2);
}
</script>
<input type="button" value="get Movie Details" onClick=Movie() />
</body>
</html>
Comments
Post a Comment