|
| 1 | + |
| 2 | + |
| 3 | +# JS | Basic Algorithms |
| 4 | + |
| 5 | +Welcome to your first bootcamp exercise at IronHack! |
| 6 | + |
| 7 | +The goal of this exercise is to get you acquainted with the different control structures we have in JavaScript. |
| 8 | + |
| 9 | +Ready? |
| 10 | + |
| 11 | +## Introduction |
| 12 | + |
| 13 | +For this Pair-Programming activity we are going to use a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). You can fine a REPL that runs in the browser for programming languages as JavaScript in [repl.it](https://repl.it/) |
| 14 | + |
| 15 | +We could also type JavaScript code in an editor, and then execute it to see the results in the REPL. |
| 16 | + |
| 17 | +Ready to start? |
| 18 | + |
| 19 | +## Requirements |
| 20 | + |
| 21 | +- Go to [repl.it](https://repl.it/languages/javascript) and create an account (or login if you have one) |
| 22 | +- Open a new repl.it and make sure the language is ==JavaScript== |
| 23 | +- Type this in the ==Code Editor== (left panel) |
| 24 | + |
| 25 | + ```javascript |
| 26 | + console.log("I'm Ready!"); |
| 27 | + ``` |
| 28 | +- Press `run ►` |
| 29 | +- If you can see the message on the JavaScript REPL, you're ready!! |
| 30 | + |
| 31 | +  |
| 32 | + |
| 33 | +## Submission |
| 34 | + |
| 35 | +When you are done and you have checked that everything works fine, go to https://gist.github.com/, create a new [secret gist](https://help.github.com/articles/about-gists/#secret-gists) and send it to your Instructor. |
| 36 | + |
| 37 | +  |
| 38 | + |
| 39 | +:::info |
| 40 | +**Remember:** Remember to add the extension of the file `fileName`**.js** in the *"Filename including extension"* input box so you can enjoy [syntax highlighting](https://en.wikipedia.org/wiki/Syntax_highlighting) in your gist |
| 41 | +::: |
| 42 | + |
| 43 | +## Exercise |
| 44 | + |
| 45 | +### Names and Input |
| 46 | + |
| 47 | +1. Create a variable `hacker1` with the driver's name |
| 48 | + |
| 49 | +2. Print `"The driver's name is XXXX"` |
| 50 | + |
| 51 | +3. Create a variable `hacker2` and [ask the user](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt) for the navigator's name |
| 52 | + |
| 53 | +4. Print `"The navigator's name is YYYY"` |
| 54 | + |
| 55 | +### Conditionals |
| 56 | + |
| 57 | +5. Depending on which name [is longer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), print: |
| 58 | + - `The Driver has the longest name, it has XX characters` or |
| 59 | + - `Yo, navigator got the longest name, it has XX characters` or |
| 60 | + - `wow, you both got equally long names, XX characters!!` |
| 61 | + |
| 62 | +### Loops |
| 63 | + |
| 64 | +6. Print all the characters of the driver's name, separated by a space and [in capitals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) |
| 65 | + ie. `"J O H N"` |
| 66 | + |
| 67 | +7. Print all the characters of the navigator's name, in reverse order. |
| 68 | + ie. `"nhoJ"` |
| 69 | + |
| 70 | +8. Depending on the [lexicographic order](https://en.wikipedia.org/wiki/Lexicographical_order) of the strings, print: |
| 71 | + - `The driver's name goes first` |
| 72 | + - `Yo, the navigator goes first definitely` |
| 73 | + - `What?! You both got the same name?` |
| 74 | + |
| 75 | +### Bonus Time! |
| 76 | + |
| 77 | +9. Ask the user for a new string and check if it's a [Palindrome](https://en.wikipedia.org/wiki/Palindrome). Examples of palindromes: |
| 78 | + - "A man, a plan, a canal, Panama!" |
| 79 | + - "Amor, Roma" |
| 80 | + - "race car" |
| 81 | + - "stack cats" |
| 82 | + - "step on no pets" |
| 83 | + - "taco cat" |
| 84 | + - "put it up" |
| 85 | + - "Was it a car or a cat I saw?" and "No 'x' in Nixon". |
| 86 | + |
| 87 | +10. Go to [lorem ipsum generator](http://www.lipsum.com/) and: |
| 88 | + - Generate 3 parragraphs. Store the text in a String |
| 89 | + - Make your program count the number of words in the string |
| 90 | + - Make your program count the number of times the latin word [`et`](https://en.wiktionary.org/wiki/et#Latin)appears |
| 91 | + |
| 92 | +## Extra Resources |
| 93 | + |
| 94 | +- [prompt() - MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt) | Ask user for input |
| 95 | +- [String - MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) |
| 96 | +- [if - MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else) |
| 97 | +- [while - MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while) |
| 98 | +- [for - MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for) |
0 commit comments