Right way to use && and || in javascript

when to use a semicolon examples
when to use a colon
how to use
semicolon vs colon
proper use of ... in a sentence
punctuation
punctuation marks
correct use of slash

I've made a little web-application. And want to make when I push 'enter' there must be check if there is empty or space value. In this case I have 'alert'.

So I used event listener. But it works incorrect. Alert appears when I push not only 'enter'. Need your help!

const convert = document.getElementById('convert');

currentValue.addEventListener('keypress', function(event) {
  if (event.which === 13 && currentValue.value === '' ||
    currentValue.value === ' ') {
    alert('value is empty');
  } else {
    convertTemperature();
  }
}, false);
<div id="application">
  <input id="currentValue" type="number">
  <select id="select">
    <option value="celsius">Celsius</option>
    <option value="fahrenheit">Fahrenheit</option>
    <option value="kelvin">Kelvin</option>
  </select>
  </br>
  <button id="convert">Convert</button>
  </br>
  <input id="value1" type="text">
  </br>
  <input id="value2" type="text">
</div>

&& has higher priory than || so you have to add () for || condition as following (currentValue.value === '' || currentValue.value === ' ')

const convert = document.getElementById('convert');

currentValue.addEventListener('keypress', function(event) {
    if (event.which === 13 )
       if(currentValue.value === '' || currentValue.value === ' ') {
          alert('value is empty');
      } else {   
            convertTemperature();
      }
}, false); 

What's the Right Way to Use a Semicolon?, Punctuation marks are like tools. The best writers know how to implement them. In this article, we examine how one of the most often misused  A set of instructions should be given to patients on sildenafil: A minimum wait of 45 minutes to 1 hour is required between taking the tablet and having sex or masturbating. In the time interval between tablet and sex, it is important to be in sexual mood and have erotic thoughts rather than


Please try this below

const convert = document.getElementById('convert');

currentValue.addEventListener('keypress', function(event) {
  if (event.which === 13) {
   if (currentValue.value === '' ||
    currentValue.value === ' ') {
    alert('value is empty');
  } else {
    convertTemperature();
  }
  }
}, false);
<div id="application">
  <input id="currentValue" type="number">
  <select id="select">
    <option value="celsius">Celsius</option>
    <option value="fahrenheit">Fahrenheit</option>
    <option value="kelvin">Kelvin</option>
  </select>
  </br>
  <button id="convert">Convert</button>
  </br>
  <input id="value1" type="text">
  </br>
  <input id="value2" type="text">
</div>

How to Use English Punctuation Correctly (with Pictures), The proper use of a semicolon is similar, but not identical, to that of a comma. The semicolon marks the end of one independent clause and the start of another  Part 1 Edging Using a Power Edger or Weed Wacker 1. Use your power edger or weed wacker primarily around sidewalks and footpaths. 2. Use your power edger along straight lines and right angles. 3. Walk holding the edging tool completely level and rigid. 4. If you can, walk on the sidewalk or


First you need a form, so you don't need to focus on the button and then check for enter.

In this case you will only need the operator.

function convertTemp(event) {
  event.preventDefault();
  let __key = event.keyCode || event.which,
    __ipVal = document.getElementById('currentValue').value;
  if (__ipVal === '' || __ipVal === ' ') {
    alert('value is empty');
  } else {
    console.log('Convert Temp')

  }
}
<div id="application">
  <form id='convertTempForm' onsubmit='convertTemp(event)'>
    <input id="currentValue" type="number">
    <select id="select">
      <option value="celsius">Celsius</option>
      <option value="fahrenheit">Fahrenheit</option>
      <option value="kelvin">Kelvin</option>
    </select>

    <button id="convert" type='submit'>Convert</button>
  </form>
  <div>
    <input id="value1" type="text">
  </div>
  <div>
    <input id="value2" type="text">
  </div>
</div>

Here's the Right Way to Use Colons and Semicolons, Everyone needs a punctuation refresher once in a while. This post will explain everything you need to know about the right way to use colons  Best Proper Way to Use a Penis Pump. Step 1: Read the Manual. I understand that it’s easy to skip this, but reading the manual is very important. You are dealing with something Step 2: Use Lubricant. This isn’t required but for additional comfort, apply a lubricant to the opening of the pump.


How to use a semicolon, If you would like a regular serving of grammar-related awesomeness every day, go follow her on Twitter. More Comics. Random Popular Latest · How much do  How To Use A Penis Pump. One of the most effective and safest ways of enlarging your penis is through the use of a penis pump.. If you’re looking to actually buy one here are more detailed reviews on the best pumps – these pumps were reviewed by the one and only: PhalloGauge Medical.


What is the right way to use the word 'literally'?, Then would be the correct use of “literally” if that person actually has a billion or more to his name. But if he's just a rich person who has a lot of money but less  Here’s the important thing you need to know: if you use the shiny side, you’re doing it right. And if you use the dull side, you’re also doing it right. According to Reynold’s Kitchen, the difference between the two sides has nothing to do with cooking. It’s just a result of manufacturing.


The Right Way to Use Compensation, Business leaders often ask, “What's the best sales compensation structure to use​?” It's a complicated question. The ideal plan is contextual—tailored to both the  Now that cannabis is legal in Canada, you should get a firm grasp on all aspects of vaping. Today we will learn how to vape weed, what it’s like to be high and how long does a high from vaping last. Given that weed is now legal, first-timers ought to learn why vaping may be one of the best ways to consume weed.