Well, i made a game based on “Space Invader” with PyGame library.
JS
//function that counts letters in strings
function count(string) {
let obj = {};
for (ch of string) {
obj[ch] ? obj[ch]++ : obj[ch] = 1;
}
return obj;
}
//function that converts rgb to hex
function rgb(r, g, b) {
return [r, g, b].map(v => {
if (v > 255) return 255;
if (v < 0) return 0;
return v;
})
.map(v => v.toString(16))
.map(v => v.length == 1 ? '0' + v : v)
.reduce((v, res) => v + res, '')
.toUpperCase();
}