Room area....did I already do a room area/paint calculator? I did...I did that room calculator. This one is for finding the amount of paint. So it's a bit of a mash up of the last exercise (pizzas) with a Math.ceil() and the area calculator. This first swipe took moments.
Fiddle: https://jsfiddle.net/NodToNothing/x4bm0cys/
All Fiddles: https://jsfiddle.net/user/NodToNothing/fiddles/
[Image]
The Code:
HTML:
Room Length:
Room Width:
Paint coverage (square feet per gallon)a:
Square Feet: {{sqFeet}}
Gallons of Paint: {{gallons}}
Javascript + Vue 2.2.1
var app = new Vue({
el: '#app',
components: {
},
data: {
length: 10,
width: 10,
coverage: 350
},
computed: {
gallons: function(){
//return ((this.pizzas * this.slices) % this.people);
//the disadvantage of f-ed up long math in line, you lose your place, that took a few iterations
return Math.ceil((this.length * this.width) / this.coverage);
},
sqFeet: function(){
return (this.length * this.width);
}
}
})
"Exercises for Programmers: 57 Challenges to Develop Your Coding Skills - Chapter 3, Paint a Room - Square"
No comments yet. -