Variable Names Are Never Enclosed in Quotation Marks

Variable Names Are Never Enclosed in Quotation Marks

<p>Variable names are never enclosed in quotation marks.</p><p>Using assignment statements: If you are assigning a variable or a property a value, the variable name or property name MUST be on the left side of the equal sign. var My_color = prompt(“what color do you like?”); var X = 54; document.body.style.color = “red”; var Fav_color = “blue”; get.Element.By.Id(“pig”).style.backgroundColor = Fav_color; Variable names are never enclosed in quotation marks. If the variable name is used anywhere other than the left side of the equal sign we want the value of the variable. var Your_age;</p><p>Your_age = x; x is a variable that has a value and we are assigning that value to the variable Your_age; document.getElementById(y).color = Fav_color; y has no quotes so it is a variable that has a value’ Here that value is an id if an element. The text color of the element with the id of the value of x is being assigned the value that the variable Fav_color has. prompt() and alert() are both JavaScript methods/functions. method/function names are followed by parentheses. prompt() and alert() are unrelated. </p><p>They both produce pop up boxed but they are unrelated. prompt() must be used in an assignment statement. A variable can only have one value.</p><p>Assigning a value to a variable. var x = 45; x = 139; var Y = 2; X = y; Y= 7; Y = 56; What is the value of x any y after the statements have executed. Only one element can have a particular id. </p><p>If you want to assign 3 elements the same background color you will need four completed JavaScript statements. document.getElementById(“pig”).color = “green”; document.getElementBy.Id(“cow”).color = “green”; document.getElementById(“dog”).color = “green”;</p><p>A tag can only have one onclick.</p><p><p onclick = “document.getElementById(‘pig’).color = ‘green’; document.getElementById(‘cow’).color = ‘green’; document.getElementById(‘dog’).color = ‘green’;”> </p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us