ParseInt & ParseFloat

Video

JavaScript Notes

JavaScript
    let log = console.log;
    let myInt = 123;
    let myStrInt = "456";
    let address = "456 Main Ave.";
    let myFloat = 123.456;
    let myStrFloat = "345.567.789.345";
    let cost = "12.99 per box";

    //parseInt parseFloat
    log(parseInt(myStrInt));     // 456    
    log(parseInt(address));      // 456 - starts from left
    log(parseFloat(address));    // 456 - starts from left
    log(parseFloat(myStrFloat)); // 345.567
    log(parseFloat(cost));       // 12.99
    log(parseInt(cost));         // 12