function rate(line) {
    let [name, rating] = line.split(" - ")
    if (catalog[name] != undefined) {
        let plant = catalog[name]
        plant.ratings.push(Number(rating))

        let total = 0
        for (let rating of plant.ratings) {
            total += rating
        }
        plant.avgRating = total / plant.ratings.length
    }else {
        console.log('error');
    }
}
// - if the plant exist in the catalog, add the given rating ( as number )
if the plant exist in the catalog, add the given rating ( as number )
if the plant exist in the catalog add the given rating ( as number )
function rate(line) {
    let [name, rating] = line.split(" - ")
    if (catalog[name] != undefined) {
        let plant = catalog[name]
        plant.ratings.push(Number(rating))
        let total = 0
        for (let rating of plant.ratings) {
            total += rating
        }
        plant.avgRating = total / plant.ratings.length
    }else {
        console.log('error');
    }
}
function rate ( line ) { let [ name , rating ] = line . split ( " - " ) if ( catalog [ name ] != undefined ) { let plant = catalog [ name ] plant . ratings . push ( Number ( rating ) ) let total = 0 for ( let rating of plant . ratings ) { total += rating } plant . avgRating = total / plant . ratings . length } else { console . log ( 'error' ) ; } }
if the plant exist in the catalog, add the given rating ( as number )
if the plant exist in the catalog add the given rating ( as number )