Life in Weeks

A visual reflection on time

You have lived about 0 weeks.

You may have about 0 weeks remaining.

You have completed about 0% of this life timeline.

"莫等闲,白了少年头,空悲切。"

Weeks Lived
Weeks Remaining

受 1.4 User Input启发想到做这个小工具

很多人第一次看到这张「人生周数图」的时候, 都会突然意识到:时间其实过得比我们想象的要快。 这个「Life in Weeks」其实并不是什么神秘的软件, 它背后的逻辑和你们刚刚在课上学到的编程思想是一样的。 很多程序看起来很复杂,但本质上都可以拆成三个简单的步骤:

1. 输入(Input)
程序先向你要一些信息,比如你的年龄、你希望活到多少岁、 以及你喜欢的颜色。这一步就和我们在课上学的 readLine()readInt() 是一样的, 让用户把数据输入进来。
2. 处理(Process)
接下来计算机会在后台做一些简单的计算。 比如:一年大约有 52 周, 所以程序会用 年龄 × 52 来算出你已经度过了多少周, 再根据你的预期寿命算出还有多少周。 这些其实就是我们在编程里最常见的:变量 + 数学运算。
3. 输出(Output)
最后,程序把结果展示出来。 它根据计算的结果,把已经度过的那些周用你喜欢的颜色标出来, 剩下的周则保持空白,于是就形成了你现在看到的这张 「人生时间地图」。

所以你会发现,一个看起来很有意思的小工具, 背后其实就是我们刚刚学到的几个基础概念: 输入 → 计算 → 输出

接下来你们的挑战就是:尝试用你们现在学到的基础 JavaScript, 写一个属于自己的小程序。它不需要这么复杂, 甚至只用文字输出也可以,但核心思想是一样的。

💻 Coding Challenge for You

Now it's your turn to build a small program. You don't need to create a visual page like this one. Instead, use the basic JavaScript skills you just learned to make a simple program that runs in the console and prints text results.

Your program should include three steps:

You can choose one of these ideas to implement:

Your program does not need to be complicated. As long as it follows the idea of Input → Calculation → Output, you have successfully built your own small program.