คำอธิบายโจทย์
เขียน 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]"
}
]