My basic javascript code not rendering on browser

why is this? I’m using notepad. Here’s my code:

Edit: Edited the mistakes in my code, how do i return stuff on the webpage?
function compareEquality(a,b) {
compareEquality("10","10");  }

shouldn’t the browser display something, like equal or not equal.
even this doesn’t work.

function testLogicalOr(val) {
if (val >10) {
return "Bigger than 10"; }
return "10 or less"; }


someone help meee :frowning:

Your both the codes has errors. There is an extra quotation mark in the first code after 10. In the second code, there is no space after the word function.

To check code output or errors you need to open browser console.

1 Like

no, it wouldn’t, you have no code that add anything to the webpage, nor a console.log that would display the result on the console

plus, you have syntax errors

1 Like

thank you. in the second code, ive added the space.
I’ve now just realised you press ctrl + shift + j , to display the console. But how do i like display stuff on the webpage like html, or can it not do that.
I’ve tried document.write() and works for simple things like
var product = 7 *2

Isn’t the code below suppose to test the value and trigger the function to run and display it?

1 Like

Fixed my errors i think. Do you know of any website I can code javascript that will tell me of my errors.

document.write displays things on the DOM.

testLogicalOr(21); will call the function and when function returns something that value will be discarded since you’re not storing or printing the value.

Store & Print

let result = testLogicalOr(21); 
console.log(result); // document.write(result);
1 Like

oh thank you so much, so i can use let result , ahhh i see.

and I can just write document.write(result); underneath the console.log and it will also display it in the browser, got it. document is for the DOM.

do you know the best way for me to see my errors, apparantely there is an error in this code? edit: oh maybe missing a }

function testLogicalOr(val) {
if (val < 10) {
return "Nice"; }
else {
return "No"; }

let cheese = testLogicalOr(31);


look at the browser console, it should show errors

1 Like