Portfolio
AddingMethodsToObject
<!DOCTYPE html>
<html>
<head>
<script type = "text/javascript">
function person(name, age){
this.name = name;
this.age = age;
this.yearsUntilRetire = yearsLeft;
}
function yearsLeft(){
var numYears = 65-this.age;
return numYears;
}
var bucky = new person("Bucky robes", 24);
</script>
</head>
<body>
<script type = "text/javascript">
document.write("65-24= "+bucky.yearsUntilRetire()+ "<br />");
var movies = new Array("Fight club", "Avatar", "The Bucket List", "Vanilla Sky");
movies.pop();
movies.push("knees","toes");
movies.reverse();
movies.sort();
var string1 = movies.join(" - ");
document.write(string1+"<br />");
var crap = new Array(3);
for(i =0;i<3;i++){
crap[i] = prompt("Add something to the array", "");
}
var st = crap.join(", ");
document.write(st);
</script>
</body>
</html>
