Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Can you Set something equal to a string/word?

Set num1 = num2 + num3 -> this makes sense to me

Set newColor = purple -> Is this allowed?

Display newColor -> would this display "purple?"

2 Answers

Relevance
  • 7 years ago
    Favorite Answer

    Typically, in any language, you need to put strings in quotes or single quotes, so Set newColor = "purple" would work and get displayed.

  • 7 years ago

    setting newColor to purple would result in the computer looking for a variable called "purple". A string is surrounded by single or double quotes.

    When you are using a word without those, the computer looks for a variable. If it does not find one with that name, you will get a "reference error".

Still have questions? Get your answers by asking now.