diff --git a/js/tests/hello-there-editor.json b/js/tests/hello-there-editor.json new file mode 100644 index 00000000..0a42329b --- /dev/null +++ b/js/tests/hello-there-editor.json @@ -0,0 +1,18 @@ +[ + { + "description": "Log a number in the console", + "code": "// If you see this code, it means that you failed the first tests.\n// each tests have it's own code to be tested that will appear if\n// your solution doesn't pass it, it is not here to help you.\n// While sometimes it may clarify the instructions\n// this specific test is complex and will most likely confuse you.\n\n// This is to save all the values that you console.log'd\nconst args = saveArguments(console, 'log')\n\n// This comment below will be replaced by your code\n// Your code\n\n// This is where we check that the value are expected.\n// It's pretty advanced code, you don't have to understand it\n// Do not try to use it for the solution, it will not help you.\nconst typeOfLoggedValues = args.flat().map((v) => typeof v)\nif (!typeOfLoggedValues.includes('number')) {\n // this is where we create the error message you see:\n throw Error('you must log a number')\n // that's what you should focus on trying to understand\n // the message, not `throw` or `Error` don't worry about\n // that, worry about showing a number in the console !\n}" + }, + { + "description": "Log a boolean in the console", + "code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nconst typeOfLoggedValues = args.flat().map((v) => typeof v)\nif (!typeOfLoggedValues.includes('boolean')) {\n throw Error('you must log a boolean')\n}" + }, + { + "description": "Log a string in the console", + "code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nconst typeOfLoggedValues = args.flat().map((v) => typeof v)\nif (!typeOfLoggedValues.includes('string')) {\n throw Error('you must log a string')\n}" + }, + { + "description": "Log the string Hello There ! in the console", + "code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('Hello There !')) {\n throw Error('you must log the text Hello There !')\n}" + } +] \ No newline at end of file diff --git a/subjects/hello-there-editor/README.md b/subjects/hello-there-editor/README.md new file mode 100644 index 00000000..39328284 --- /dev/null +++ b/subjects/hello-there-editor/README.md @@ -0,0 +1,70 @@ +## Hello There 👋 + +### Values + +There are 3 types of values, and they can model the **WORLD** !\ +_(In the end it's all `1`'s and `0`'s for the computer)_, but us, **humans**, need +an easier way of representing stuff. + +> We can all agree that `11010001100101110110011011001101111` is not a very +> friendly way to say `'hello'` ! + +#### Numbers 🔢 + +- Whole numbers: `1`, `23`, `232139283` +- Negative numbers are prefixed with `-`: `-1`, `-1231` +- Decimal numbers: `3.14`, `-2.53343` etc... + +Use them for _quantities_ like in daily life. + +#### Booleans ✖️ / ✔️ + +We use them when something is either `true` or `false`. + +They can be used to represent an answer to a closed-ended question _(anything that can +be answered with yes or no)_. + +> We would answer the question *Is your screen turned on ?* +> with the value `true` _(most likely)_. + +#### Strings 🆒 + +- `'Hello'` +- `'This is some text'` + +A string is a sequence of characters used to represent text, it needs +**delimiters** to define its _begining_ and _end_.\ +Delimiters are matching quotes, either `` ` ``, `"` or `'`. + +### Using `console.log` + +To display output from a script into a console, use the function `console.log`: + +```js +console.log() // <- will show an empty line +``` + +Add any value between the parentheses to see it appear when the script is +executed. + +> It is very important to use this often to validate that our code is valid. The +> more it is tested, the easier it is to understand what's going on in the code +> ! +> +> In doubt, `console.log` everything, don't be shy, they are for free. + +### Instructions + +In the editor block, write a program that displays: + +- the exact text `Hello There !` +- any `Number` +- and a `Boolean`. + +### Recommendation + +Videos designed to give **hints** are assigned to each quest. It is strongly suggested to watch them as you go. + +### You will learn about + +- JavaScript primitive values