Edit: Edited the mistakes in my code, how do i return stuff on the webpage?
<script>
function compareEquality(a,b) {
compareEquality("10","10"); }
</script>
shouldn’t the browser display something, like equal or not equal.
even this doesn’t work.
<script>
function testLogicalOr(val) {
if (val >10) {
return "Bigger than 10"; }
return "10 or less"; }
testLogicalOr(21);
</script>
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.
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
document.write(product)
Isn’t the code below suppose to test the value and trigger the function to run and display it?
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);