Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var newColor = {
- r: 255,
- g: 100,
- b: 50
- }
- // with ES6
- function flattenRGB = obj => Object.keys(obj).map(v => obj[v]).join();
- var rgb = `rgb(${flattenRGB(newColor)})`;
- // vanilla JS
- function flattenRGB(obj) {
- return Object.keys(obj).map(function (v) {
- return obj[v];
- }).join();
- }
- var rgb = "rgb(" + flattenRGB(newColor) + ")";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement