You have to use ==
to compare (or even ===
, if you want to compare types). A single =
is for assignment.
if (one == 'rock' && two == 'rock') {
console.log('Tie! Try again!');
}
More Related Contents:
- Which Logic Operator Takes Precedence
- Why does javascript accept commas in if statements?
- How to code a calculator in JavaScript without ‘eval’
- JQuery .hasClass for multiple values in an if statement
- How to add a black shadow on top of a div block with background image?
- javascript: hiding contents of key
- jQuery Ajax POST example with PHP
- What is the difference between JSON and Object Literal Notation?
- Creating a textarea with auto-resize
- Response to preflight request doesn’t pass access control check
- How to append to a file in Node?
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- HTML button to NOT submit form
- Is it possible to use JS to open an HTML select to show its option list? [duplicate]
- How to load all the images from one of my folder into my web page, using Jquery/Javascript
- jquery clone form fields and increment id
- Javascript with jQuery: Click and double click on same element, different effect, one disables the other
- Why can’t I reliably capture a mouseout event?
- Is JQGrid free?
- How to include Javascript in xml-document?
- Changing the layout of a component depending on Redux state
- When should you NOT use React memo?
- ES2015 “import” not working in node v6.0.0 with with –harmony_modules option
- Programmatically change Redux-Form Field value
- How can I disable print-screen functionality for a webpage in all browsers?
- Load external JS from bookmarklet?
- javascript TypeError: document.getElementsByTagName(“p”)[0].innerHtml is not a function
- Chrome extension: Block page items before access
- Shrinking font-size at a user types to fit in an input using Javascript
- Vanilla JS event delegation – dealing with child elements of the target element