Question

JavaScript expert, I need your help : My program doesn't work. I have the following program,...

JavaScript expert, I need your help : My program doesn't work.

I have the following program, it is simple web page:

Create an object called person with name = John, age = 50. Then, access the object to display "John is 50 years old”. I have written some code here.

Hint: Create an object with the var keyword, followed by a name and an "=" sign.

Put the properties and values inside the {}; signs

Note: Use getElementById() and innerHTML to display your output.Create an object called person with name = John, age = 50. Then, access the object to display "John is 50 years old”. I have written some code here.

Hint: Create an object with the var keyword, followed by a name and an "=" sign.

Put the properties and values inside the {}; signs

Note: Use getElementById() and innerHTML to display your output.

-------------------------------------------------

<html>

<body>

<p id="demo">Display the result here.</p>

<script>

var person = {name: "John", age: 50};

document.getElementById("demo").innerHtml = person.name + " is " + person.age + " years old.";

</script>

</body>

</html>

0 0
Add a comment Improve this question Transcribed image text
Answer #1
<html>

<body>

<p id="demo">Display the result here.</p>

<script>

var person = {name: "John", age: 50};

document.getElementById("demo").innerHTML = person.name + " is " + person.age + " years old.";

</script>

</body>

</html>

Output:

\color{red}Note:\;It \;is \;innerHTML \;not \;innerHtml\;

\color{red}Please\; upvote\;the \;solution \;if \;it \;helped.\;Thanks!

Add a comment
Know the answer?
Add Answer to:
JavaScript expert, I need your help : My program doesn't work. I have the following program,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" />...

    This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" /> </head> <body> <script type ="text/javascript"> //declare a variable and store text in it var x = "JavaScript is fun"; //write the variable 5 times document.write(x + x + x + x + x); //store 5 as string in variable x x = "5"; //store 3 as string in variable y var y = "3"; //write the value x + y to the document document.write("<br>");...

  • Need help with these scenarios Question 1 Write a JavaScript program to get the volume of...

    Need help with these scenarios Question 1 Write a JavaScript program to get the volume of a Cylinder with four decimal places using object classes. Volume of a cylinder : V = πr2h where r is the radius and h is the height of the cylinder. Your solution must include an HTML and a JavaScript file, with a button to create the cylinder, inputs for the cylinder's radius and height and an output to show the cyclinder's volume. Your solution...

  • JAVASCRIPT Hello, I would like some help there are the directions: You have 5 employees. Write...

    JAVASCRIPT Hello, I would like some help there are the directions: You have 5 employees. Write a program that asks for the employee name and their total sales for the month. Calculate their commission which is10% of the total sales. They will receive a bonus based on their total sales. Sales Bonus 0 - 1000 0 1001 - 10000 100 Over 10000 1000 Display each of the employee’s commission and bonus. After all 5 employees have been entered, display the...

  • Can someone please help me with this javascript - Javascript - do at least 10 of...

    Can someone please help me with this javascript - Javascript - do at least 10 of the following questions below ----------------------------------------------------------------------------------- Create an HTML file that takes in input and carries out of the following functions and manipulates the DOM to show the outcome. Please put the question itself as a comment above each answer. Use either JavaScript, jQuery, or both (but know the difference!). ----------------------------------------------------------------------------------- 1. Fibonacci Define function: fib(n) Return the nth number in the fibonacci sequence. 2....

  • I have some code for HTML/Javascript but I need to change it up a bit. Heres...

    I have some code for HTML/Javascript but I need to change it up a bit. Heres the assignment and what I have. The part in the bold is what I need help with. I need a button called new timer for when it reaches zero... Thank you. Assignment For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration" with the initial...

  • I need help with my javascript project, I've started on it but I can't seem to...

    I need help with my javascript project, I've started on it but I can't seem to get ym java scripts to work with my index.html. Can someone please help me fix my code? I need the main.js & scratchpad.js to work with my index.html .Thank you Directions: Go to the following link: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics On that page, scroll down to "A 'hello world' example". Follow the step-by-step instructions to download their code and edit it in your text editor of choice....

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • Hello, this is my code. moest of the things works but when select the price, i...

    Hello, this is my code. moest of the things works but when select the price, i just dont get my total. can someone help me out . thank you My queshion is also here The page will simulate the site for a Chicago-based small bus line that travels to St Louis, Milwaukee, and Detroit. Here are the requirements: The home page (i.e. the main page) should simply be the heading, image, and slogan of the site.  The home page should NOT...

  • i need the code that goes within the <script> opening and closing following the insturctions of...

    i need the code that goes within the <script> opening and closing following the insturctions of the insturctions of the pasted assignment screen shots please. <!DOCTYPE html> <html> <head> <!-- JavaScript 6th Edition Chapter 3 Hands-on Project 3-1 Filename: index.htm --> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <title>Hands-on Project 3-1</title> <link rel="stylesheet" href="styles.css" /> <script src="modernizr.custom.05819.js"></script> </head> <body> <header> <h1> Hands-on Project 3-1 </h1> </header> <article> <h2>Lunch selections</h2> <form> <input type="checkbox" id="item1" value="8" /> <label for="item1">Fried chicken ($8.00)</label> <input type="checkbox"...

  • QUOTE OF THE DAY not totally working in JAVA I need to fix this code, the...

    QUOTE OF THE DAY not totally working in JAVA I need to fix this code, the problem that I have is that I have to include before the listed quotes , one of the quotes and the date and later are the listed quotes. Now when I run it , it only shows the title and the list of quotes. I have been trying to figure out the problem, any help...? I need it to run the title "Quote of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT