This JavaScript script calculates and logs various statistics related to life, including the percentage of life spent sleeping and masturbating, based on assumptions of 7 hours of sleep per night and 1 hour of masturbation per day. The output includes the percentage of life spent sleeping, the percentage of the year spent masturbating, and the percentage of life spent masturbating.
// calculate exact age based on current date
var _daysUntilBirthday = (_currentDate.getMonth() + 1) / 11 * 365.25 + (_currentDate.getDate() - 12);
var _daysLifeOfBrian = (_currentDate.getFullYear() - 1986) * 365.25 - _daysUntilBirthday;
var _32exactYearsLifeOfBrian = _daysLifeOfBrian / 365.25;
var _7hoursPerNight = 7;
var _1hourPerDay = 1;
// percent of life spent sleeping (verification of methodology)
var _daysPerYearSleeping = _7hoursPerNight / 24 * 365.25;
var _percentOfYearSleeping = _daysPerYearSleeping / 365.25;
var _percentOfYearSleepingFormatted = Math.round(_percentOfYearSleeping * 10000) / 100 + '%';
console.log('Percent of life spent sleeping (1/3 of life): ' + _percentOfYearSleepingFormatted)
// percent of life spent masturbating
var _daysPerYearJerking = _1hourPerDay / 24 * 365.25;
var _percentOfYearJerking = _daysPerYearJerking / 365.25;
var _percentOfYearJerkingFormatted = Math.round(_percentOfYearJerking * 10000) / 100 + '%';
var _percentOfLifeJerking = _percentOfYearJerking * (_32exactYearsLifeOfBrian - 12) / _32exactYearsLifeOfBrian; // Since age 12
var _percentOfLifeJerkingFormatted = Math.round(_percentOfLifeJerking * 10000) / 100 + '%';
console.log('Percent of year spent masturbating: ' + _percentOfYearJerkingFormatted);
console.log('Percent of life spent masturbating: ' + _percentOfLifeJerkingFormatted);
// percent of life spent not working
// percent of life spent watching movies
// Date constants
const BIRTH_YEAR = 1986;
const CURRENT_DATE = new Date();
// Calculate exact age
function calculateDaysUntilBirthday(currentDate) {
return currentDate.getDate() - 12;
}
function calculateDaysLifeOfBrian(currentYear) {
const daysUntilBirthday = calculateDaysUntilBirthday(CURRENT_DATE);
return (currentYear - BIRTH_YEAR) * 365.25 - daysUntilBirthday;
}
function calculateExactYearsLifeOfBrian(daysLifeOfBrian) {
return daysLifeOfBrian / 365.25;
}
// Calculate sleep data
function calculateDaysPerYearSleeping(hoursPerNight) {
return (hoursPerNight / 24) * 365.25;
}
function calculatePercentOfYearSleeping(daysPerYearSleeping) {
return daysPerYearSleeping / 365.25;
}
function calculatePercentOfYearSleepingFormatted(percentOfYearSleeping) {
return Math.round(percentOfYearSleeping * 10000) / 100 + '%';
}
const SLEEP_HOURS_PER_NIGHT = 7;
const SLEEP_PERCENTAGE = calculatePercentOfYearSleeping(calculateDaysPerYearSleeping(SLEEP_HOURS_PER_NIGHT));
// Calculate masturbation data
function calculateDaysPerYearJerking(hoursPerDay) {
return (hoursPerDay / 24) * 365.25;
}
function calculatePercentOfYearJerking(daysPerYearJerking) {
return daysPerYearJerking / 365.25;
}
function calculatePercentOfYearJerkingFormatted(percentOfYearJerking) {
return Math.round(percentOfYearJerking * 10000) / 100 + '%';
}
function calculatePercentOfLifeJerking(percentOfYearJerking, exactYearsLifeOfBrian) {
const age = 12; // Since age 12
return percentOfYearJerking * (exactYearsLifeOfBrian - age) / exactYearsLifeOfBrian;
}
function calculatePercentOfLifeJerkingFormatted(percentOfLifeJerking) {
return Math.round(percentOfLifeJerking * 10000) / 100 + '%';
}
const JERKING_HOURS_PER_DAY = 1;
const JERKING_PERCENTAGE = calculatePercentOfYearJerking(calculateDaysPerYearJerking(JERKING_HOURS_PER_DAY));
const JERKING_PERCENTAGE_OF_LIFE = calculatePercentOfLifeJerking(JERKING_PERCENTAGE, calculateExactYearsLifeOfBrian(calculateDaysLifeOfBrian(CURRENT_DATE.getFullYear())));
// Log results
console.log('Percent of life spent sleeping:'+ calculatePercentOfYearSleepingFormatted(SLEEP_PERCENTAGE));
console.log('Percent of year spent masturbating:'+ calculatePercentOfYearJerkingFormatted(JERKING_PERCENTAGE));
console.log('Percent of life spent masturbating:'+ calculatePercentOfLifeJerkingFormatted(JERKING_PERCENTAGE_OF_LIFE));
Overview
The provided code is a JavaScript script that calculates various statistics related to life, including the percentage of life spent sleeping and masturbating.
Variables
The code defines the following variables:
_daysUntilBirthday
: calculates the number of days until the current day's birthday_daysLifeOfBrian
: calculates the number of days since 1986_32exactYearsLifeOfBrian
: calculates the exact age of "Life of Brian" (based on 1986 birth year)_7hoursPerNight
: number of hours spent sleeping per night (7 hours)_1hourPerDay
: 1 hour per day for masturbation (used in later calculations)_daysPerYearSleeping
: calculates the number of days per year spent sleeping_percentOfYearSleeping
: calculates the percentage of the year spent sleeping_percentOfYearSleepingFormatted
: formatted percentage of the year spent sleeping_daysPerYearJerking
: calculates the number of days per year spent masturbating_percentOfYearJerking
: calculates the percentage of the year spent masturbating_percentOfYearJerkingFormatted
: formatted percentage of the year spent masturbating_percentOfLifeJerking
: calculates the percentage of life spent masturbating (since age 12)_percentOfLifeJerkingFormatted
: formatted percentage of life spent masturbatingCalculations
The code performs the following calculations:
Output
The code logs the following output to the console: