frankcollins3 / fill_container

codecamp team project updated with new icon screen menu + puppeteer icon search, GraphQL, redux, relational psql !mongo, and accuweatherAPI
1 stars 0 forks source link

NaN but also !== "number" [4:19pm] #241

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: 👍 color: clock < 45 ? "#DC143C" : "silver" this works

<div style={{ display: clock === NaN ? "none" : "", color: clock < 45 ? "#DC143C" : "silver"}} >

// attempting to parse for number type because when the timer runs out it becomes NaN && need not be displayed.

error: Screen Shot 2023-06-20 at 4 17 53 PM

proposed approach: 0: already tried this: <div style={{ display: typeof clock !== "number" ? "none" : "", color: clock < 45 ? "#DC143C" : "silver"}} >

1: run logs get types and work backwards from values returned by logs()

frankcollins3 commented 1 year ago

<div style={{ display: typeof clock == "number" ? "" : "none", color: clock < 45 ? "#DC143C" : "silver"}} > [4:20pm]

frankcollins3 commented 1 year ago

heres the code making the below output logged from chrome tools:
console.log('timer') console.log(timer) console.log(typeof timer)

logs indicating typeof undefined Screen Shot 2023-06-20 at 4 24 42 PM

should be ez fix. 👍 only take 5 minutes doing this. if typeof is undefined though

with viable solution in viewport, still confused: <div style={{ display: typeof clock == "number" ? "" : "none", color: clock < 45 ? "#DC143C" : "silver"}} > code in which the typeof for which the comparison is run against is a number, and the actual number is undefined Falsy block never triggered?

[4:24pm]

frankcollins3 commented 1 year ago

👍 kind of confused why the above statements don't work but this one does.

  return (      
    <div style={{ color: 'silver', fontWeight: 'bolder'}} className="timer">      
      { typeof timer === "number" ? "Next Reminder:" : "" }
      { typeof timer === "number" ? renderTimer() : "" }
    {/* <p> {typeof timer === "number" ? "yesnumber" : "nonumber" } </p> */}
    </div>
  );

[4:48pm]