You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/2/en/part2b.md
+8-10Lines changed: 8 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -401,7 +401,7 @@ You can find the code for our current application in its entirety in the <i>part
401
401
402
402
In the first exercise, we will start working on an application that will be further developed in the later exercises. In related sets of exercises, it is sufficient to return the final version of your application. You may also make a separate commit after you have finished each part of the exercise set, but doing so is not required.
403
403
404
-
<h4>2.6: The Phonebook Step1</h4>
404
+
<h4>2.6: The Phonebook Step 1</h4>
405
405
406
406
Let's create a simple phonebook. <i>**In this part, we will only be adding names to the phonebook.**</i>
407
407
@@ -459,13 +459,13 @@ Note the use of the React developer tools extension in the picture above!
459
459
- you can use the person's name as a value of the <i>key</i> property
460
460
- remember to prevent the default action of submitting HTML forms!
461
461
462
-
<h4>2.7: The Phonebook Step2</h4>
462
+
<h4>2.7: The Phonebook Step 2</h4>
463
463
464
464
Prevent the user from being able to add names that already exist in the phonebook. JavaScript arrays have numerous suitable [methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) for accomplishing this task. Keep in mind [how object equality works](https://www.joshbritz.co/posts/why-its-so-hard-to-check-object-equality/) in Javascript.
465
465
466
466
Issue a warning with the [alert](https://developer.mozilla.org/en-US/docs/Web/API/Window/alert) command when such an action is attempted:
467
467
468
-

468
+

469
469
470
470
**Hint:** when you are forming strings that contain values from variables, it is recommended to use a [template string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals):
471
471
@@ -487,7 +487,7 @@ newName + ' is already added to phonebook'
487
487
488
488
Using template strings is the more idiomatic option and the sign of a true JavaScript professional.
489
489
490
-
<h4>2.8: The Phonebook Step3</h4>
490
+
<h4>2.8: The Phonebook Step 3</h4>
491
491
492
492
Expand your application by allowing users to add phone numbers to the phone book. You will need to add a second <i>input</i> element to the form (along with its own event handler):
493
493
@@ -503,11 +503,11 @@ At this point, the application could look something like this. The image also di
503
503
504
504

505
505
506
-
<h4>2.9*: The Phonebook Step4</h4>
506
+
<h4>2.9*: The Phonebook Step 4</h4>
507
507
508
508
Implement a search field that can be used to filter the list of people by name:
509
509
510
-

510
+

511
511
512
512
You can implement the search field as an <i>input</i> element that is placed outside the HTML form. The filtering logic shown in the image is <i>case insensitive</i>, meaning that the search term <i>arto</i> also returns results that contain Arto with an uppercase A.
513
513
@@ -528,7 +528,7 @@ const App = () => {
528
528
529
529
This saves you from having to manually input data into your application for testing out your new functionality.
530
530
531
-
<h4>2.10: The Phonebook Step5</h4>
531
+
<h4>2.10: The Phonebook Step 5</h4>
532
532
533
533
If you have implemented your application in a single component, refactor it by extracting suitable parts into new components. Maintain the application's state and all event handlers in the <i>App</i> root component.
534
534
@@ -560,8 +560,6 @@ const App = () => {
560
560
}
561
561
```
562
562
563
-
**NB**: You might run into problems in this exercise if you define your components "in the wrong place". Now would be a good time to rehearse
564
-
the chapter [do not define a component in another component](/en/part1/a_more_complex_state_debugging_react_apps#do-not-define-components-within-components)
565
-
from the last part.
563
+
**NB**: You might run into problems in this exercise if you define your components "in the wrong place". Now would be a good time to rehearse the chapter [do not define a component in another component](/en/part1/a_more_complex_state_debugging_react_apps#do-not-define-components-within-components) from the last part.
0 commit comments