Ask coding questions

← Back to all posts
?Am I Close?" ( Javascript)
faziz6006 (2)

function exerciseOne(UserClass){
// Exercise One: In this exercise you are given a class called UserClass.
// You will be adding a method to the prototype called greeting
// This method will return the string: 'Hello, it is nice to meet you!'
// DO NOT create a new class or object

// Please write your code in the lines above
return UserClass
}


my answer ( it says its wrong?) :

prototype.greeting = function (){

return Hello, it is nice to meet you!;

};

var prototype = new greeting;

Answered by vedprad1 (727) [earned 5 cycles]
View Answer
Commentshotnewtop
vedprad1 (727)

If you really want the final code, it is here. However, you should try looking at online resources rather than asking for answers here.

function exerciseOne(UserClass) {
  UserClass.prototype.greeting = function () {
    return "Hello, it is nice to meet you!";
  };
}

If this answer is correct, please check the checkmark on the left side of this message. Thanks and Good Luck!

faziz6006 (2)

@vedprad1 bro im trying to do this so i can qualify for an online class with a teacher and stuff , i am trying its just so hard plus this time i had some answer

vedprad1 (727)

You forgot the prototype of what.
Because you are given UserClass, you have to add the function to its prototype.
eg:

UserClass.prototype.greeting...

If this answer is correct, please check the checkmark on the left side of this message. Thanks and Good Luck!

faziz6006 (2)

@vedprad1 stil no luck how shod i the final code look

mwilki7 (279)

Make sure you have the right type of quotes surrounding your return statement

faziz6006 (2)

@mwilki7 like this?

return "Hello, it is nice to meet you!";