Jump to content

rissa146

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by rissa146

  1. 3) Add a lives property and subtractLife and addLife methods that will increment or decrement a player's lives. A new player should start off with 3 lives.
    function PlayerConst(userName, score, highScore) {
    this.username = userName;
    this.score = score;
    this.highScore = highScore;
    this.gameOver.reset = score;

    }

    }


    PlayerConst.prototype.update = function update(){
    this.score++;
    if(this.score > this.highScore){
    this.highScore = this.score;
    }

    PlayerConst.prototype.lives = function lives(){
    this.addLife = addLife++;
    this.subtractLife = subtractLife--;
    }

    new PlayerConst.prototype.lives(3);

  2. Create a Shape constructor function that has a height and width property. Include a method that will calculate the area of the shape, where area is defined as the shape's height multiplied by its width.



    function shapeFunct(x,y){
    this.height = x;
    this.width = y;
    return x * y;
    }

    // call the function shapeFunct(100,100);

  3. I am creating a Shape constructor function that has a height and width property. Include a method that will calculate the area of the shape, where area is defined as the shape's height multiplied by its width. Does this look right?



    function shapeFunct(x,y){
    this.height = x;
    this.width = y;
    return x * y;
    }

    // call the function shapeFunct(100,100);
  4. I just saw my error.

     

    var str = "clarissa";
    function someStr(str){
    var i;
    var vLent = str.length;
    var cntArr = 0;
    var ch;
    for (i=0; i<vLent; i++){
    ch = str.charAt(i).toUpperCase();
    if ((ch == 'A') || (ch == 'E') || (ch == 'I') || (ch == 'O') || (ch == 'U')) {
    cntArr++;
    }
    }
    return cntArr;
    }
    //to call function
    someStr(str)
  5. Thanks. I tried this

     

    var str = "clarissa"
    function someStr(str){
    var i;
    var vLent = str.length
    var cntArr = 0
    var ch;
    for (i=0, i<vLent, i++){
    ch str.charAt(i).toUpperCase();
    if ((ch == 'A') || (ch == 'E') || (ch == 'I') || (ch == 'O') || (ch == 'U')) {
    cntArr++;
    }
    }
    return cntArr;
    }
    I know there is an error. I just don't know where. I am very very new at this coding and any point in the right direction will help
×
×
  • Create New...