AI Nativeレベル別課題

レベル1 · 基礎 · データと入力

入れ子のログから秘密を隠す

入れ子のオブジェクトと配列の機密項目を隠します。

問題文

function solution(logs, fields)を書いてください。入出力はJSON値です。入力配列やオブジェクトを変更しないでください。外部ライブラリ・ネットワーク・非同期関数は使えません。 logs:JSON[], fields:string[]. Match object keys case-insensitively against fields without trimming. Replace the entire matching value with '[REDACTED]'. Recurse into other objects and arrays; retain primitives and null. Preserve all keys, including '__proto__'. Maximum depth 20. Return a new array in input order. 入力範囲:各入力配列は最大50,000項目、文字列は最大1,000文字です。数値は有限値で、整数と整数の合算結果はJavaScriptの安全な整数範囲内です。その他の型と有効性は上記の規則に従います。

入出力例

例 1

関数の引数

[
  [
    {
      "token": "abc",
      "message": "ok"
    }
  ],
  [
    "token"
  ]
]

戻り値

[
  {
    "token": "[REDACTED]",
    "message": "ok"
  }
]
例 2

関数の引数

[
  [
    {
      "nested": {
        "PASSWORD": "p"
      },
      "tags": [
        "x"
      ]
    }
  ],
  [
    "password"
  ]
]

戻り値

[
  {
    "nested": {
      "PASSWORD": "[REDACTED]"
    },
    "tags": [
      "x"
    ]
  }
]
例 3

関数の引数

[
  [
    {
      "user": {
        "name": "Alex"
      },
      "token": null
    }
  ],
  [
    "token"
  ]
]

戻り値

[
  {
    "user": {
      "name": "Alex"
    },
    "token": "[REDACTED]"
  }
]
Practice has no points, deadline or submission cap. Use AI and search freely. Sign in to run public examples, or verify locally.

71 / 20,000文字

Add your test · optional

Enter a JSON argument array in logs, fields order. Your test runs alongside the three examples.

Save both files in one folder and run this command with Node.js. Read the checks field for individual example results.

node verify-redact-logs.mjs
문의하기

서비스명: 포트포올
문의는 운영자에게 이메일로 전송됩니다.

이메일과 문의 내용은 답변을 위해 운영자 및 메일 발송 서비스로 전송됩니다. 비밀번호·결제정보·민감한 개인정보는 입력하지 마세요.