Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. var newColor = {
  2. r: 255,
  3. g: 100,
  4. b: 50
  5. }
  6.  
  7. // with ES6
  8. function flattenRGB = obj => Object.keys(obj).map(v => obj[v]).join();
  9.  
  10. var rgb = `rgb(${flattenRGB(newColor)})`;
  11.  
  12. // vanilla JS
  13. function flattenRGB(obj) {
  14. return Object.keys(obj).map(function (v) {
  15. return obj[v];
  16. }).join();
  17. }
  18.  
  19. var rgb = "rgb(" + flattenRGB(newColor) + ")";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement