JS - Logical operators OR || AND && NOT!

0 votes
559 views
added Jul 6, 2018 in Javascript by LC Marshal Captain (25,790 points)
edited Jul 12, 2018 by LC Marshal
// || OR logical operator
let result = prompt('what should be the Messi jersey number', '');
if ( result == (11 || 10)) {  
  alert( 'Most likely' );
} else if ( result == (null || '')) {
  alert('Please answering');
} else {
  alert ('couldnt be');
}

6 Responses

0 votes
responded Jul 6, 2018 by LC Marshal Captain (25,790 points)
edited Jul 12, 2018 by LC Marshal
console.log( null || 2 || undefined ); //The answer is 2, that’s the first truthy value.
console.log( 1 && null && 2 ); //The answer: null, because it’s the first falsy value from the list.
0 votes
responded Oct 22, 2019 by LC Marshal Captain (25,790 points)
if(this.searchListing && this.listingSearchFilters.username) {
  data.username = this.searchListing;
  data.username = this.listingSearchFilters.username
}

 

0 votes
responded Oct 23, 2019 by LC Marshal Captain (25,790 points)
if (newFile && (!oldFile || newFile.file !== oldFile.file)) {
  // Create a blob field
  newFile.blob = "";
  let URL = window.URL || window.webkitURL;
  if (URL && URL.createObjectURL) {
    newFile.blob = URL.createObjectURL(newFile.file);
  }

  // Thumbnails
  newFile.thumb = "";
  if (newFile.blob && newFile.type.substr(0, 6) === "image/") {
    newFile.thumb = newFile.blob;
  }
}

 

0 votes
responded Oct 23, 2019 by LC Marshal Captain (25,790 points)
if (newFile.active && !oldFile.active) {
  // beforeSend
    // Extention
  let ext = newFile.name.substring(newFile.name.lastIndexOf(".")+1).toLowerCase();
  if(ext != "pdf"){
   this.$refs.upload.update(newFile, { error: "extention" });
  }
  // min size
  if (
    newFile.size >= 0 &&
    this.minSize > 0 &&
    newFile.size < this.minSize
  ) {
    this.$refs.upload.update(newFile, { error: "min_size" });
  }
  //max size
  if (
    newFile.size >= 0 &&
    this.size > 0 &&
    newFile.size >= this.size
  ) {
    this.$refs.upload.update(newFile, { error: "max_size" });
  }

   var reader = new FileReader();
    reader.readAsDataURL(newFile.file);
    reader.onload = (e)=>  {
       var image = new Image();
       image.src = e.target.result;
       let contxt =  this;
        image.onload = function(){
          img_width = this.width;
          img_height = this.height;
          if(img_width <200 || img_height < 200){
             contxt.$refs.upload.update(newFile, { error: "width_height" });
          }
        }
    };
}

 

0 votes
responded Oct 23, 2019 by LC Marshal Captain (25,790 points)
if (newFile.error && !oldFile.error) {
  // error
  if(!this.content){
    this.content = document.createElement("div");
    this.content.style.maxHeight = "450px";
    this.content.style.overflow  = "auto";
  }
  let message =newFile.response.message ? newFile.response.message : '';
  let countfile = "";
  let countfilecount = "";
  this.fileFailed++;
  if(message == "" || message == undefined){
   // countfile = this.fileFailed+" File failed\n";
      if(newFile.error != undefined && newFile.error == 'min_size'){
          message ="Image is too small to upload.";
        }else if(newFile.error != undefined && newFile.error == 'extention'){
          message ="Only pdf file types are allowed.";
        }else if(newFile.error != undefined && newFile.error == 'max_size'){
          message ="Maximum image size to upload is 7MB.";
        }else if(newFile.error != undefined && newFile.error == 'width_height'){
          message ="Minimum image dimension is - Width : 200px, Height : 200px.";
        }else{
          message ="Unsupported Image.";   
        }
        if(this.fileFailed > 1){
          message = countfile +message;
        }/*else{
          message = this.message1+this.message2+this.message3+this.message4+this.message5;
        }*/
  }
  this.createErrorMessage(message,newFile.name);
  
   if(this.$refs.upload && this.$refs.upload.uploaded && this.isBulkUpload == 1){
    if(this.fileSuccess == 0){
      countfilecount = this.fileFailed+" File(s) failed to upload\n";
    }else{
      countfilecount = this.fileFailed+" File(s) failed to upload\n"+ this.fileSuccess+" File uploaded successfully";
    }
     this.$swal({
        title: "Oops",
        text: countfilecount,
        content: this.content,
        icon: "warning"
      });
  }else if(this.isBulkUpload == 0){
       this.$swal({
        title: "Oops",
        text: message,
        icon: "warning"
      });
  }
}

 

0 votes
responded Oct 24, 2019 by LC Marshal Captain (25,790 points)
else if ($('body').hasClass(excptThisPage) || $('body').hasClass(excptThisPage2)) {
 $('.sto-ads').hide();  
}

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...