蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

用失败、修复和回归测试核对结果

JAVASCRIPTWindows x64 本地离线练习。Python 3.12 或 Node.js 22 及以上。greeting.cjs
greeting.cjs24 行
function greeting(record) {
    const username = typeof record?.username === 'string' ? record.username.trim() : '';
    return 'Hello, ' + (username || 'Guest') + '!';
}

function compareBindings() {
    const shared = [];
    const perIteration = [];
    for (var index = 0; index < 3; index++) {
        shared.push(() => index);
    }
    for (let index = 0; index < 3; index++) {
        perIteration.push(() => index);
    }
    return [shared.map(read => read()), perIteration.map(read => read())];
}

if (require.main === module) {
    const record = JSON.parse(process.argv[2] || '{}');
    console.log(JSON.stringify({message: greeting(record), bindings: compareBindings()}));
}

module.exports = {greeting, compareBindings};
本例需在 Windows x64 本地离线练习。Python 3.12 或 Node.js 22 及以上。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Windows x64 本地离线练习。Python 3.12 或 Node.js 22 及以上。

入口文件:projects/claude-code-foundations/greeting.cjs

本地运行步骤快速上手
  1. 点击上方“保存源码”保存为 greeting.cjs,或下载右侧课程工程包。
  2. 确认本地已准备 Windows x64 本地离线练习。Python 3.12 或 Node.js 22 及以上。。
  3. 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载

下载课程关联工程包:Claude Code

课程关联工程包(登记关联2章) · 含当前章节或实例 · mbskycom202612a3126.zip

下载课程关联工程包:Claude Code

课程关联工程包(登记关联42章) · 含当前章节或实例 · mbskycom202612a3117.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习