Use emoji strings

This commit is contained in:
Sosuke Suzuki 2024-04-01 14:04:52 +09:00 committed by Philip Chimento
parent 065ccc121e
commit b73f7d662d
2 changed files with 8 additions and 8 deletions

View File

@ -11,12 +11,12 @@ includes: [compareArray.js]
features: [array-grouping, Map]
---*/
const string = 'abcd';
const string = '🥰💩🙏😈';
const map = Map.groupBy(string, function (char) {
return char < 'c' ? 'before' : 'after';
return char < '🙏' ? 'before' : 'after';
});
assert.compareArray(Array.from(map.keys()), ['before', 'after']);
assert.compareArray(map.get('before'), ['a', 'b']);
assert.compareArray(map.get('after'), ['c', 'd']);
assert.compareArray(map.get('before'), ['💩', '😈']);
assert.compareArray(map.get('after'), ['🥰', '🙏']);

View File

@ -11,12 +11,12 @@ includes: [compareArray.js]
features: [array-grouping]
---*/
const string = 'abcd';
const string = '🥰💩🙏😈';
const obj = Object.groupBy(string, function (char) {
return char < 'c' ? 'before' : 'after';
return char < '🙏' ? 'before' : 'after';
});
assert.compareArray(Object.keys(obj), ['before', 'after']);
assert.compareArray(obj.before, ['a', 'b']);
assert.compareArray(obj.after, ['c', 'd']);
assert.compareArray(obj.before, ['💩', '😈']);
assert.compareArray(obj.after, ['🥰', '🙏']);