I am trying to have an adjustable height for separate columns based on different percentages compared to other users data.
function Person(name, points) {
"use strict";
this.name = name;
this.points = points;
this.height = 0;
}
var daniel = new Person('Daniel', '2');
var boaz = new Person('Boaz', '4');
var josh = new Person('josh', '5');
Person.prototype.getHeight = function () {
"use strict";
var scores = [daniel.height, boaz.height, josh.height],
highest = 0,
i = 0;
for (i; i < scores.length; i += 1) {
if (scores[i] > highest) {
highest = scores[i];
}
}
this.height = String(this.points / highest);
return this.height;
};
$(document).ready(function () {
"use strict";
var $daniel = daniel.getHeight() + '%',
$boaz = boaz.getHeigt() + '%',
$josh = josh.getHeight + '%';
$('#daniel').height($daniel);
$('#boaz').height($boaz);
$('#josh').height($josh);
});
basically all this code does is creates three different person with different point levels, and then sets their heights according to the percent value compared to the person with the highest score. E.G. I have ten points and you have three points, I would be 100 and you would be 3. I then use jQuery to convert this to % and try to resize the individual ids according to the percentage.
For some reason nothing is showing up when I do this on the actual page. What is going wrong? I am assuming that it has something to do with the jQuery, as the normal javascript is doing fine.