Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function User(Name, Email) {
- this.prototype = {
- User : function(Name, Email){
- this.Name = Name;
- this.Email = Email;
- QuizScores = new Array();
- CurrentScore = 0;
- },
- saveScore: function (theScoreToAdd) {
- QuizScores.push(theScoreToAdd);
- CurrentScore += theScoreToAdd;
- },
- showNameAndScores: function () {
- var result = "Name " + Name + " Scores: ";
- if (QuizScores.length == 0) result += "No scores yet."
- for (var i = 0; i < QuizScores.length; ++i) {
- if (i != QuizScores.length - 1)
- result += QuizScores[i] + ", ";
- else
- result += QuizScores[i] + ".";
- }
- return result;
- },
- changeEmail: function (newEmail) {
- Email = newEmail;
- },
- }
- }
- User.prototype.constructor = User;
- var user1 = new User("Michael", "michael6@gmail.com");
- var user2 = new User("Johnny", "johnny@gmail.com");
- var user3 = new User("Elvis", "TheKing@yahoo.com");
- function onLoadFunction() {
- document.getElementById("paragraph1").innerHTML = user1.prototype.showNameAndScores() +
- "<br>" + user2.prototype.showNameAndScores() + "<br>" + user3.prototype.showNameAndScores();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement