Skip to content

Commit 6c82f43

Browse files
committed
Implement new exercises on expressions, variables, and control flow
- Add exercises for expressions and output, including logging and string manipulation. - Introduce variable assignments and reassignment concepts. - Create control flow exercises focusing on conditionals and loops. - Update README and FINISHED files to guide learners through new content. - Ensure consistency in TypeScript type annotations across exercises.
1 parent 840e9ec commit 6c82f43

File tree

139 files changed

+534
-74
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+534
-74
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Hello World
2+
3+
👨‍💼 Every programmer starts here: printing "Hello, World!" to the screen.
4+
5+
The `console.log()` function takes a value and prints it to the terminal. This
6+
is how you see the results of your code.
7+
8+
🐨 Open <InlineFile file="index.ts" /> and complete the following tasks:
9+
10+
1. Use `console.log()` to print the string `"Hello, World!"`
11+
2. Use `console.log()` to print your name as a string
12+
13+
💰 Strings are text values wrapped in quotes:
14+
15+
```ts
16+
console.log('This is a string')
17+
console.log('Double quotes work too')
18+
```
19+
20+
🐨 Once you've completed the exercise, run `node index.ts` in the playground to
21+
see your output!
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Your First Program
2+
// Let's print some messages to the console!
3+
4+
// 🐨 Use console.log() to print "Hello, World!"
5+
6+
// 🐨 Use console.log() to print your name (as a string)
7+
8+
export {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "exercises_01.expressions-and-output_01.problem.hello-world",
3+
"type": "module",
4+
"scripts": {
5+
"start": "node index.ts",
6+
"test": "node --test index.test.ts"
7+
}
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Hello World
2+
3+
👨‍💼 You did it! You've written your first lines of code.
4+
5+
`console.log()` is one of the most useful tools you have. Whenever you're
6+
confused about what a value is, just log it!
7+
8+
🦉 Notice that strings can use either single quotes (`'`) or double quotes
9+
(`"`). In this workshop, we'll use single quotes, but both work identically.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import assert from 'node:assert/strict'
2+
import { execSync } from 'node:child_process'
3+
import { test } from 'node:test'
4+
5+
await test('should print Hello, World!', () => {
6+
const output = execSync('node index.ts', { encoding: 'utf8' })
7+
assert.ok(
8+
output.includes('Hello, World!'),
9+
'🚨 Output should include "Hello, World!" - make sure you used console.log() with that exact string',
10+
)
11+
})
12+
13+
await test('should print at least two lines', () => {
14+
const output = execSync('node index.ts', { encoding: 'utf8' })
15+
const lines = output.trim().split('\n').filter(Boolean)
16+
assert.ok(
17+
lines.length >= 2,
18+
'🚨 Output should have at least 2 lines - make sure you logged both Hello, World! and your name',
19+
)
20+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Your First Program
2+
// Let's print some messages to the console!
3+
4+
console.log('Hello, World!')
5+
6+
console.log('Kody')
7+
8+
export {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "exercises_01.expressions-and-output_01.solution.hello-world",
3+
"type": "module",
4+
"scripts": {
5+
"start": "node index.ts",
6+
"test": "node --test index.test.ts"
7+
}
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# String Expressions
2+
3+
👨‍💼 Strings are one of the most common types of data in programming. Let's
4+
explore what you can do with them.
5+
6+
You can combine strings together using the `+` operator. This is called
7+
**concatenation**:
8+
9+
```ts
10+
console.log('Hello' + ' ' + 'World') // Prints: Hello World
11+
```
12+
13+
🐨 Open <InlineFile file="index.ts" /> and complete the following tasks:
14+
15+
1. Log the result of concatenating `"Hello"` and `"TypeScript"` with a space
16+
between them
17+
2. Log your first name and last name concatenated together
18+
3. Log a longer message by concatenating multiple strings
19+
20+
💰 Remember to include spaces where you need them - the `+` operator joins
21+
strings exactly as they are!
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// String Expressions
2+
// Learn to work with text data
3+
4+
// 🐨 Log "Hello" + " " + "TypeScript" (concatenate these three strings)
5+
6+
// 🐨 Log your first name and last name concatenated together with a space
7+
8+
// 🐨 Log a sentence by concatenating multiple strings
9+
// 💰 Example: "I" + " " + "am" + " " + "learning" + " " + "to" + " " + "code"
10+
11+
export {}

exercises/05.void-and-never/01.solution.void-functions/package.json renamed to exercises/01.expressions-and-output/02.problem.strings/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "exercises_05.void-and-never_01.solution.void-functions",
2+
"name": "exercises_01.expressions-and-output_02.problem.strings",
33
"type": "module",
44
"scripts": {
55
"start": "node index.ts",

0 commit comments

Comments
 (0)