# JavaScript Objects- Can you confirm?

Ok, I am in a JavaScript class, and I have no desire for anyone to do my schoolwork, I have already done what I think is correct, I am just hoping someone can take a look and tell me if I am close, or right, or whatever. Any feedback appreciated. Also, the instructor was very specific in saying that if it asks for a line of code, then just do a line of code- so if it appears things are missing that would be why.

1.Write a line of code using the Location object to return the uniform resource locator (URL) of a Web page to a variable called myWebPage.

function getLocation(){


2.Write a line of code using the Navigator object to return the Web browser name to a variable called myBrowserName.

function getLocation(){


3.Write a line of code using the Screen object to return the height of the display screen, not including operating system features such as the Windows Taskbar, to a variable called myScreenHeight

function getLocation(){


4.Write a line of JavaScript code using the Window object and other properties to open a new Web browser window with www.google.com displaying and no menu bar

function getWindow(){


That's it! Let me know if I did anything wrong, thank you!

-

## migrated from stackoverflow.comApr 27 '12 at 18:38

This question came from our site for professional and enthusiast programmers.

@CorbinHolbert This may be better for our Code Review site. I'll migrate it for you, and then you can watch there as people help evaluate your code. –  Jonathan Sampson Apr 27 '12 at 18:37

Three small changes for numbers 1, 2, and 3 as it says they should be assigned to variables.

1.Write a line of code using the Location object to return the uniform resource locator (URL) of a Web page to a variable called myWebPage.

var myWebPage = document.location.href;

2.Write a line of code using the Navigator object to return the Web browser name to a variable called myBrowserName.

var myBriowserName = navigator.appName;

3.Write a line of code using the Screen object to return the height of the display screen, not including operating system features such as the Windows Taskbar, to a variable called myScreenHeight

var myScreenHeight = screen.height;

Otherwise it looks good at first glance.

-
So I did number four right though? I guess I was overcomplicating things. At first I had exactly what you just typed up and I looked at it and thought "no way, that's too simple" :/ –  Corbin Holbert Apr 27 '12 at 22:40
You could remove it from the function, the inner line is all you really need. –  jzworkman Apr 27 '12 at 22:51

It looks like you're not following the instructions strictly. For example, here:

1.Write a line of code using the Location object to return the uniform resource locator (URL) of a Web page to a variable called myWebPage.

You didn't write a line of code, you wrote two, and you alerted the value instead of assigning to the variable. You also used a function, where the requirements do not include a function. I think the instructor is expecting something like this:

var myWebPage = window.location.href;

-

Give up on putting everything in functions, especially when the question does not ask for a function but for a line of code (it probably means "a single statement").

Pay attention when the question requests that the value be put in a variable.

-