Need help figuring out format & no output


#1

Hello everyone. I'm very new at learning JavaScript and am currently trying to figure out why my code as it sits won't work. I have a JS Bin account and the file I'm having the trouble with is shared at the following link...
http://jsbin.com/mikewooz/last

Please keep in mind that I'm practicing and trying different things to see how they interact. I'm not sure if it's me or something that I might have configured wrong on JS Bin.

Truthfully, I believe the problem probably lies with how I have the code arranged. I will greatly appreciate any help gently tweaking what I got, otherwise I won't learn from the mistakes made here.

Best,
Mike


#2

Hi @doc3 and welcome to the forums.
By taking a look at the console there are several errors that need addressing:

Firstly you seem to be missing a double quote at the end of the following line :
document.getElementById("div1").innerHTML = "<p>" + "Temperature is " + temperature + "</p>;

Try addressing that and let us know if it still doesn't work.

All the best,

Andres


#3

So yeah, pretty much the only things tripping you up atm are quotes and keeping straight when you've started and stopped a string.
The end of the line that Andres pointed out needs a " before the ;.
The /n's in your alert should have quotes around them, and +'s inserted before them. (Note that they're black in the editor, this is a hint. Any literal characters you're trying to output should be red in this editor. Things in black = variable names, etc.)
(Also the slash for escaping characters like newlines is \, rather than / :wink: )


#4

Andres, worked great as far as displaying the temp in div... I had to complete the steps suggested by another member to get it to work fully. Thanks so much for your advice.


#5

After making your suggested changes, the program worked perfectly... thanks a million for your assistance.


#6

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.