I saved it as a .html file. Like it can display simple stuff, like console.log(21) , or in the past, with var products and other stuff… It is not displaying in browser.
I’m on the boolean if statement bit of javascript freecodecamp excercises…
What’s wrong with my code.?
Also, to space out my numbers, like my seperate bits of script, is
paragraphs advisable?
My code, il take out the script tags between them so u can see it:
document.write(21)
function testGreaterThan(val) {
if (val > 100) {
return "Over 100";
}
if (val > 10) {
return "Over 10";
}
return "10 or Under";
}
console.log(10)
/
// stopped working .
var testArr = [1,2,3,4,5];
function nextInLine(Arr, item) {
// Only change code below this line
Arr.push(item);
var removed = Arr.shift();
return removed;
// Only change code above this line
}
<p> </p>
function equalityTest(myVal) {
if (myVal == 10) {
return "Equal";
}
return "Not Equal";
}
myVal(10);
/
// Doesn't work.
// function functionWithArgs(param1,param2) {
// console.log(param1 + param2); }
// functionWithArgs(3,1);
// document.write(functionWithArgs)
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
thanks , but do you know why my javascript isnt correctly running and displaying the results? is it because im using notepad? on my windows laptop
cool
Hello~!
To clarify, are you trying to get your JavaScript code to render something in the browser?
1 Like
Yes I am, I just want it to return stuff. Like, I have that bit of code for
myVal(10);
it should return Equal., the other stuff doesn’t work either,
the variable removed should be returned too …?
console.log(10)
will print “10” to the console, but it will not render anything in the actual browser window. I apologise if I’m repeating myself, but I want to be sure I understand the objective so I don’t end up pointing you in the wrong direction.
Do you want it to print something to the browser console? Or render something in the actual view window?
1 Like
Render something in the actual view window. My code should be returning the results and such.
I didnt know there was such a place called the console,
like code like this works and outputs 36:
<script>
var product = 6*6
document.write(product);
</script>
Yeah I just want to know why the webpage is blank when im opening my code in a .html page in the browser.
Do i need script tags between each like bits of code when i introduce a new function, should i close the script tag and open up a new one?