5.A. AIM: 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 lang="en">
<head>
<title>Render Movie Description</title>
</head>
<body>
<script>
var moviedesc = {'moviename':'Yama Gola', 'starring' : 'Srikanth', 'language' : 'Telugu', 'rating' : 5.6}
for(var key in moviedesc){
document.write(key+" : "+moviedesc[key]+"<br>")
}
</script>
</body>
</html>
5.B. AIM: Simulate a periodic stock price change and display on the console. Hints: (i) Create a method which returns a random number - use Math.random, floor and other methods to return a rounded value. (ii) Invoke the method for every three seconds and stop when you get 10 prices.
<html lang="en">
<head>
<title>Random Number Generator</title>
</head>
<body>
<p>This page displays 10 random numbers generated with help of Math functions.</p>
<p>See the numbers in console window.</p>
<script>
var i=1
numberGenerater()
function numberGenerater(){
var num = Math.random()*101
num = Math.floor(num)
console.log(num+"\n")
if(i<=10){
i++
setTimeout(numberGenerater, 3000)
}
}
</script>
</body>
</html>
5.C. AIM: Validate the user by creating a login module. Hints: (i) Create a file login.js with a User class. (ii) Create a validate method with username and password as arguments. (iii) If the username and password are equal it will return "Login Successful" else return "Invalid User Name or Password".
Login.jsvalidate(username, password){
if(username==password){
return "Login Successful"
}else{
return "Invalid Username and Password"
}
}
}
function loginValidate(){
var username = document.login.uname.value
var password = document.login.upwd.value
var u = new User()
window.alert(u.validate(username,password))
}
<html>
<head>
<title>Login</title>
<script src="Login.js"></script>
</head>
<body>
<form name="login">
<table align="center" cellspacing="15px">
<tr>
<td><b>User Name</b></td>
<td><input type="text" name="uname" required/></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="upwd" required/></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="Login" onclick="loginValidate()"/>
<input type="reset" />
</td>
</tr>
</table>
</form>
</body>
</html>