Closed MityaDementiy closed 1 year ago
Hi, @kendru! I have noticed logical issue while working with Section 4 code, Writing pure functions section. Now I see there this code:
(defn target-label-for-input-unit [unit] (case unit :fahrenheit "F" :celsius "C")) (defn convert [unit temp] (if (= :celsius unit) (c->f temp) (f->c temp))) (defn update-output [_] (let [unit (get-input-unit) input-temp (get-input-temp) output-temp (convert unit input-temp) output-label (target-label-for-input-unit unit)] (set-output-temp output-temp) (gdom/setTextContent output-unit-target output-label)))
When I run this code, I get C output label when use Celsius input and F when use Fahrenheit input. But I expect to see F output label when using Celsius input. I assume code should be fixed that way:
(defn target-label-for-output-unit [unit] (case unit :fahrenheit "C" :celsius "F")) (defn convert [unit temp] (if (= unit :celsius) (c->f temp) (f->c temp))) (defn update-output [_] (let [unit (get-input-unit) input-temp (get-input-temp) output-temp (convert unit input-temp) output-label (target-label-for-output-unit unit)] (set-output-temp output-temp) (gdom/setTextContent output-unit-target output-label)))
Thank you for your tremendous work on this book!
Hi, @kendru! I have noticed logical issue while working with Section 4 code, Writing pure functions section. Now I see there this code:
When I run this code, I get C output label when use Celsius input and F when use Fahrenheit input. But I expect to see F output label when using Celsius input. I assume code should be fixed that way:
Thank you for your tremendous work on this book!