+ 2
displaying NAme
//why does not display Name <!DOCTYPE html> <html> <body> <h1>JavaScript console.log() Method</h1> <p>Press F12 on your keyboard to view the message in the console view.</p> <p>This example demonstrates how an object is displayed in the console view.</p> <script> var myObj = { firsname : "John", lastname : "Doe" }; console.log(myObj); </script> </body> </html> //Somebody can tell why not gives answer for the name to display in this code??
1 Respuesta
+ 2
Here's the correct code
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript console.log() Method</h1>
<p>Press F12 on your keyboard to view the message in the console view.</p>
<p>This example demonstrates how an object is displayed in the console view.</p>
<script>
var myObj = { firstname : "John", lastname : "Doe" };
console.log(myObj.firstname+" "+myObj.lastname);
</script>
</body>
</html>