Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

style.fill not taking a variable

ANSWERED

Hello all (again!),

 

I have a function that receives a couple of arguments, then uses those arguments.The function has no problem receiving the correct info, but when I use the one for color, the function fails.  Any thoughts?

 

function mainClock(loadColor, loadZone) {  

  let today = new Date();
  let hours = today.getHours();
  let mins = util.zeroPad(today.getMinutes());
  let myAMPM;
  let timeZone = util.stripQuotes(loadZone);
  
  console.log(`loadColor <${loadColor}>`);
  
  time1.style.fill = loadColor;
  ampm.style.fill = loadColor;
  myTZ.style.fill = loadColor;
  myTZ.text = timeZone;
  

The console.log shows the proper color "red", "blue" quotes and all, however Iget error messages that terminate with the loadColor (I can post more of the code, if it helps).  If I replace loadColor with "red" or "blue", everything works.  I have tried = JSON.stringify(loadColor) with no change in results.  The timeZone works like a champ.  What am I missing?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I wonder about 'quotes and all'. I suspect that the value you should be assigning should be something like

red

and not

"red"
Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
2 REPLIES 2

I wonder about 'quotes and all'. I suspect that the value you should be assigning should be something like

red

and not

"red"
Peter McLennan
Gondwana Software
Best Answer
0 Votes

That did it.  I stripped the quotes off inside the variable and it is now working.

 

Thanks!

Best Answer
0 Votes