"What are you learning today?"

One of my friends (hi fnenu!) will occasionally check in with me and ask, "What are you learning today?" 

This simple, clarifying question helps motivate me, and keeps me on track. If you have a friend to program with, you've basically struck gold. Make sure to ask each other what you're learning today. If you're programming on your own, write the question out on a sticky note and put it someplace where you'll see it every morning. 

Today, I'm wrapping up the first version of my tempConverter project, which my friend Ben gave me as a challenge (hi Ben!). I plan to revisit it to add a basic front end and account for rounding, but here's the vanilla js version of the code.

// build a function to convert one temp in C, F or K to another temp in C, F or K
// Plan: Convert your 'from' temp to K first, then convert that 'temp in K' to the'to' temp. This will cut down on the number of conversion equation functions you have to write. 
// TODO: build a front end
var convert = {
    // store functions as objects within the convert object 
    fToK: function(temp) {
        return ((5*(temp-32) /9) + 273.15);
    cToK: function(temp) {
        return temp+273.15;
    kToK: function(temp) {
        return temp;
    kToF: function(temp) {
        return (9/5)*(temp-273.15) + 32;
    kToC: function(temp) {
        return temp-273.15;
function tempConverter (config) {
// TODO: add conditions 
    // if config is an object
    // else if config has three arguments
        // turn into an obj
    // else print error 
// first, convert to your bridge temperature ('K')
    var tempInK = convert[config.from.toLowerCase() + 'ToK'](config.value);
// second, convert the 'K' temperature to your 'to' temperature
    return convert['kTo' + config.to.toUpperCase()](tempInK);
// Test suite (write this FIRST)
// convert 10 C to F
var a = tempConverter({
    value: 10,
    from: 'C',
    to: 'F'
// convert 0 C to K
var b = tempConverter({
    value: 58.2,
    from: 'F',
    to: 'C'
// test output
// 50
// 14.5555...       <-- TODO: deal with rounding!