Null type checks is not considered by the tests length
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- testing
研究方向
先閱讀 4-count-types.js 及其相關測試,以了解 countTypesInArray 目前如何被限制為 200 個字元。根據 issue 討論,決定是否應明確計算 null,或是否應變更測試預期,然後驗證所選行為已受到涵蓋,同時不違反練習的長度要求。
由索引模型根據 Issue 內容生成。
描述
There is a problem with countTypesInArray function (4-count-types.js). The tests require a solution to be 200 signs max, but in this case, we kinda lose the check for nulls.
As you know null in JavaScript has a type of object. Thus, the implementation you require will count objects but not nulls. So, the function is not suitable for checking all the JS types.
I clearly understand that such a check can be done using a ternary operator but it's not convenient and intuitive enough.
The implementation below considers this JS's quirk:
const data = [
false,
'a',
22,
'hey',
undefined,
42,
12,
true,
{ a: 12 },
{ name: 'Jack' },
'foo',
'bar',
true,
null,
undefined,
Symbol('a'),
null
];
const countTypesInArray = data => {
const h = {};
for (const item of data) {
if (typeof item === 'object' && item === null) {
h['null'] = 1;
if (h['null'] > 0) {
h['null']++;
}
} else if (typeof item in h) {
h[typeof item]++;
} else {
h[typeof item] = 1;
}
}
return h;
};
console.log(countTypesInArray(data));
So, maybe you should consider an option for making tests a little bit more loose for null checks.
- 主要語言
- JavaScript
- 星號
- 39
- 分支
- 228
- PR 合併指標
- 30 天內沒有已合併 PR
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
HowProgrammingWorks/DataTypes 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 55/100
HowProgrammingWorks/DataTypes#153 ·
-
HowProgrammingWorks/DataTypes#4 · 已指派 1 人 ·
-
難度 2/5 1-3 小時 新手友好度 48/100
-
HowProgrammingWorks/DataTypes#2 · 已指派 2 人 ·
查看 HowProgrammingWorks/DataTypes 的全部 Issue
相似的 Issue
-
Edit: CW+ 未關閉channels:edit check:passed
難度 2/5 1-3 小時 新手友好度 68/100
-
難度 2/5 1-3 小時 新手友好度 78/100
idean3885/claude-ops-agent#521 ·
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
難度 1/5 1 小時以內 新手友好度 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
難度 2/5 1-3 小時 新手友好度 84/100