rissa146
-
Posts
13 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by rissa146
-
-
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); -
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); -
function myFunct(x,y){
this.x ; 100;
this.y 100
return x *y;
}
// to call the function write MyFunct(5,2)
-
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?
-
someStr(str)<-3
-
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 functionsomeStr(str) -
That's why I asked for steps, not answers.
-
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.
-
Thanks. I tried this
var str = "clarissa"function someStr(str){var i;var vLent = str.lengthvar cntArr = 0var 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 -
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.
-
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?
Adding Properties and creating methods
in JavaScript
Posted
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);