Dynamic programming task
const badgeClasses = cn(styles[`cr-badge`], {
[styles[`${baseClass}--default`]]: !(success || danger || info || important || warning),
[styles[`${baseClass}--success`]]: success,
[styles[`${baseClass}--danger`]]: danger,
[styles[`${baseClass}--info`]]: info,
[styles[`${baseClass}--important`]]: important,
[styles[`${baseClass}--warning`]]: warning,
[styles[`${baseClass}--small`]]: small,
[styles[`${baseClass}--pill`]]: pill,
});
When it comes, to variable declaration, you basically face dynamic programming problem. You don't know exactly how to convert badgeClasses, but you know, how to convert other variables.
So, on some step you will face trivial problem, when variable is going to be declared as is.
Like, for badgeClass you will face success variable, which is coming from props.
Dynamic programming task
When it comes, to variable declaration, you basically face dynamic programming problem. You don't know exactly how to convert
badgeClasses, but you know, how to convert other variables.So, on some step you will face trivial problem, when variable is going to be declared as is.
Like, for
badgeClassyou will facesuccessvariable, which is coming from props.