From 9a4b251976b7d2abbe503fff789108772dbe83df Mon Sep 17 00:00:00 2001 From: Andrea Bianchi Date: Sat, 14 Mar 2026 12:08:37 +0900 Subject: [PATCH] w3 exercises --- w3_1_arrays/arrays.js | 6 ++++++ w3_1_arrays/index.html | 16 ++++++++++++++ w3_1_arrays/objects.js | 48 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 w3_1_arrays/arrays.js create mode 100644 w3_1_arrays/index.html create mode 100644 w3_1_arrays/objects.js diff --git a/w3_1_arrays/arrays.js b/w3_1_arrays/arrays.js new file mode 100644 index 0000000..980fef8 --- /dev/null +++ b/w3_1_arrays/arrays.js @@ -0,0 +1,6 @@ +const paragraph = `Call me Ishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off- then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.`; + +// Print a frequency counter of all the letters of the alphabet appearing in the paragraph +// Ignore case + +console.log('Frequency Counter: ...'); diff --git a/w3_1_arrays/index.html b/w3_1_arrays/index.html new file mode 100644 index 0000000..0cce74a --- /dev/null +++ b/w3_1_arrays/index.html @@ -0,0 +1,16 @@ + + + + + + + + Types + + + + + + + + diff --git a/w3_1_arrays/objects.js b/w3_1_arrays/objects.js new file mode 100644 index 0000000..9da7cbd --- /dev/null +++ b/w3_1_arrays/objects.js @@ -0,0 +1,48 @@ +/** + * typedef {{name:string, age:number, job:string}} Person + * + */ +const persons = [ + { name: 'John', age: 30, job: 'Developer' }, + { name: 'Mary', age: 25, job: 'Designer' }, + { name: 'Peter', age: 27, job: 'Developer' }, + { name: 'Jane', age: 22, job: 'Designer' }, + { name: 'Bob', age: 33, job: 'Developer' }, + { name: 'Alice', age: 35, job: 'Manager' }, + { name: 'Tim', age: 32, job: 'Designer' }, + { name: 'Sara', age: 21, job: 'Designer' }, + { name: 'Tom', age: 34, job: 'Developer' }, + { name: 'Alex', age: 24, job: 'Manager' }, + { name: 'John', age: 30, job: 'Manager' }, + { name: 'Mary', age: 25, job: 'Designer' }, + { name: 'Peter', age: 27, job: 'Developer' }, + { name: 'Jane', age: 22, job: 'Designer' }, + { name: 'Bob', age: 33, job: 'Developer' }, + { name: 'Alice', age: 35, job: 'Manager' }, + { name: 'Tim', age: 32, job: 'Designer' }, + { name: 'Sara', age: 21, job: 'Designer' }, + { name: 'Tom', age: 34, job: 'Developer' }, + { name: 'Alex', age: 24, job: 'Developer' }, +]; + +/** + * averageAge. + * + * @param {Person[]} persons + */ +function averageAge(persons) { + // placehlder +} + +console.log('Average age:', averageAge(persons)); + +/** + * listJobs. + * + * @param {Person[]} persons + */ +function listJobs(persons) { + // placehlder +} + +console.log('List of jobs:', listJobs(persons));