# Doubt in setting the input to ' ' inside a function

**URL:** <https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261>\
**Category:** Learn\
**Created:** [March 7, 2022, 10:54am UTC](https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261 "2022-03-07T10:54:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaishnavi\_A.N](https://avatars.discourse-cdn.com/v4/letter/v/13edae/32.png) [@vaishnavi\_A.N](https://discourse.mozilla.org/u/vaishnavi_A.N)\
**Post date:** [March 7, 2022, 10:54am UTC](https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261/1 "2022-03-07T10:54:54Z")

</div>

Inside a function , I have seen the following code.

```auto
 const searchName = input.value.toLowerCase();
  input.value = '';

```

In the above code,in the 2nd line, input.value=’ ', makes the string empty instead of storing the name,then how this code serves the purpose?

The above example is taken from loops of mdn,[exiting loops with break statement]I have pasted the link below.

> **[Looping code - Learn web development | MDN](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Scripting/Loops)**
>
> Programming languages are very useful for rapidly completing repetitive tasks, from multiple basic calculations to just about any other situation where you've got a lot of similar items of work to complete. Here we'll look at the loop structures...

---

<div class="post-metadata">

**Author:** ![mikoMK](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/mikomk/32/50456_2.png) [@mikoMK](https://discourse.mozilla.org/u/mikoMK)\
**Post date:** [March 7, 2022, 1:02pm UTC](https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261/2 "2022-03-07T13:02:10Z")

</div>

Hi @vaishnavi_A.N

The value of the input gets stored in the first line as “searchName”. The second line prepares the input field for the next input by clearing it. Further down you see the saved input value (as searchName) being used to look it up in “contacts”.

I hope that helps. 🙂  
Michael

---

<div class="post-metadata">

**Author:** ![vaishnavi\_A.N](https://avatars.discourse-cdn.com/v4/letter/v/13edae/32.png) [@vaishnavi\_A.N](https://discourse.mozilla.org/u/vaishnavi_A.N)\
**Post date:** [March 7, 2022, 3:16pm UTC](https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261/3 "2022-03-07T15:16:01Z")

</div>

Yeah got it @mikoMK,sorry for such silly question 😅

---

<div class="post-metadata">

**Author:** ![mikoMK](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/mikomk/32/50456_2.png) [@mikoMK](https://discourse.mozilla.org/u/mikoMK)\
**Post date:** [March 7, 2022, 3:57pm UTC](https://discourse.mozilla.org/t/doubt-in-setting-the-input-to-inside-a-function/94261/4 "2022-03-07T15:57:36Z")

</div>

There are no silly questions, just silly answers 😄
