Jump to content

rissa146

Members
  • Posts

    13
  • Joined

  • Last visited

Everything 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. Thanks For your code function countVowels(str){ var i; var len = str.length; var vowel_cnt = 0; var ch; You are passing a string into the array called len and then increment by 1. is this correct?
  5. 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)
  6. I am looking for a tutorial that can help me navigate this new coding language as I have a hard time articulating what needs to be done.
  7. 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
  8. Does anyone know the steps to 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.
  9. I need to Create a function that takes a string as its input and returns the number of vowels that appear in the string. Can you write the steps for completing this action or provide a youtube video that does?
×
×
  • Create New...