Giter Site home page Giter Site logo

Line 27 about learning-area HOT 3 CLOSED

mdn avatar mdn commented on May 25, 2024
Line 27

from learning-area.

Comments (3)

chrisdavidmills avatar chrisdavidmills commented on May 25, 2024

Which example are you referring to? "Line 27" doesn't really help me ;-)

Anyway, I'm guessing that you are looking at an example featuring a form input element, and in the JavaScript we are checking whether the input is empty or not.

input.value = '' checks whether the input is empty, i.e. if its value is an empty string.

input.value = ' ' on the other hand is checking whether the input value is equal to a single space character, so will fail if it is anything else.

Does that answer your question? If not, please give me some more details, and I will help you further.

All the best.

from learning-area.

ranjanrnj44 avatar ranjanrnj44 commented on May 25, 2024

"Sorry I forgot to post the code"

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
  </head>

  <body>
   <label for="search">Name : </label>
  <input id="search" type="text">
  <button>Search</button>

  <p></p>
    
    <script>
     let input = document.querySelector("input");
      let btn = document.querySelector("button");
      let para = document.querySelector("p");

      btn.addEventListener(`click` , function(){
        let val = input.value.toLowerCase();
        //console.log(val);'
   input.value = "";
        input.focus();
        let contacts = [`ranjan:12345` , `jan:78906` , `ran:56882`];
        for(let i=0 ; i<contacts.length ; i++){
          let contact = contacts[i];
          //console.log(contact);
          let split_it = contact.split(":");
          //console.log(split_it);
          if(val === split_it[0].toLowerCase()){
            para.textContent = `So, you're looking for ${split_it[0]} of ${split_it[1]}`;
            break;
          }
          else{
            para.textContent = `Sorry, couldn't find the result`;
          }
        }
      });
    </script>
  </body>
</html>

input.value = ""; (is the line) . And now I'm clear by our explanation, It was really helpful, Thank you.

from learning-area.

chrisdavidmills avatar chrisdavidmills commented on May 25, 2024

Good, glad it helped ;-)

from learning-area.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.