w3.1 added

This commit is contained in:
Andrea Bianchi 2025-03-10 09:21:11 +09:00
parent d939ae93e8
commit 0fac72a5a8
4 changed files with 69 additions and 1 deletions

2
.gitignore vendored
View File

@ -3,5 +3,5 @@ node_modules/**
.git/**
.DS_Store
todo
*/*_solution
*/*_solution.*
TODO/**

4
w3_1_arrays/arrays.js Normal file
View File

@ -0,0 +1,4 @@
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

16
w3_1_arrays/index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Types</title>
</head>
<body>
<script src="arrays.js" defer></script>
<script src="objects.js" defer></script>
</body>
</html>

48
w3_1_arrays/objects.js Normal file
View File

@ -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(averageAge(persons));
/**
* listJobs.
*
* @param {Person[]} persons
*/
function listJobs(persons) {
// placehlder
}
console.log(listJobs(persons));