// написать функцию, которая преобразует kebab-case в camelCase
const camelize = (string) => {
// код
};
console.log(camelize('my-long-word')); // myLongWord
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const colorToRGBA = (colorString, alpha) => { | |
if (colorString.startsWith('rgb(')) { | |
const rgb = colorString | |
.slice(4, colorString.length - 1) | |
.split(',') | |
.map((item) => +item.trim()); | |
return `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${alpha})`; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const colorToRGB = (colorString) => { | |
if (colorString.startsWith('rgba(')) { | |
const rgba = colorString | |
.slice(5, colorString.length - 1) | |
.split(',') | |
.map((item) => +item.trim()); | |
const background = [255, 255, 255]; | |
const rgb = [ | |
Math.round((rgba[3] * (rgba[0] / 255) + (1 - rgba[3]) * (background[0] / 255)) * 255), | |
Math.round((rgba[3] * (rgba[1] / 255) + (1 - rgba[3]) * (background[1] / 255)) * 255), |