Javascript not working for me!


#1

won't work !!!!!!!!!!!!!!11


#2

If you expect answers or help you at least need to ask a question... JavaScript unlike HTML+CSS is a programming (scripting language) so it might take some more time to get used to its grammar aso.


#3

hi there
i have just started here and im stuck at the prompt code, would u help me please

i typed
prompt("where are you from?");

and i get an error and out put is null
y?
regards


#4

The code is fine so I would refresh the page and try again


#5

Also if you get null perhaps try to answer your prompt and press ok instead of cancel.


#6

thank you so much for ur help earlier

yes it worked after i wrote the answer ;D

regards.


#7

hi there,
can u help me please

is this a valid code?

var nameString = function (name)
{
return "Hi, I am" + " " + name;
};

console.log = nameString("sherif");

it keeps saying:
Oops, try again. It looks like you didn't print anything to the console! Did you remember to console.log() the result of passing your name to the nameString() function?


#8

Sry seemed like I'd missed this one. The problem here is that you overwrite console.log with this line:

console.log = nameString("sherif");

To fix it, it needs to be replaced by an acutal function call of console.log:

console.log(nameString("sherif"));

and maybe a refresh is necessary to reset console.log to it's old value.


#9

thanks a million

can u look at this please

var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function(sideLenth) {
     return this.sideLength * 4;
    };
square.calcArea = function(sideLenth) {
      return this.sideLenth * this.sideLenth;
     };

square.calcArea(7);
square.calcPerimeter(5);

error:Oops, try again. Your method failed when sideLength was 0 where it returned NaN instead of 0


#10

It will be easier for others to answer your questions if you create your own post for each issue rather than using @locario 's post. So you should make a new post in the relevant category and then people will be able to help you :smile:


#11

u r right
will do

thank u