Why pay a fortune teller when you can just program your fortune yourself?
Store the following into variables: number of children, partner's name, geographic location, job title.
Output your fortune to the screen like so: "You will be a X in Y, and married to Z with N kids."
var numKids = 5;
var partner = 'David Beckham';
var location = 'Costa Rica';
var jobTitle = 'web developer';
var future = 'You will be a ' + jobTitle + ' in ' + location + ', and married to ' +
partner + ' ' + ' with ' + numKids + ' kids.';
console.log(future);
The Age Calculator
Forgot how old you are? Calculate it!
Store the current year in a variable.
Store your birth year in a variable.
Calculate your 2 possible ages based on the stored values.
Output them to the screen like so: "You are either NN or NN", substituting the values.
var year = 1984;
var now = 2012;
var age = now - year;
console.log('You are either ' + age + ' or ' + (age - 1));
The Lifetime Supply Calculator
Ever wonder how much a "lifetime supply" of your favorite snack is? Wonder no more!
Store your current age into a variable.
Store a maximum age into a variable.
Store an estimated amount per day (as a number).
Calculate how many you would eat total for the rest of your life.
Output the result to the screen like so: "You will need NN to last you until the ripe old age of X".
var age = 28;
var maxAge = 100;
var numPerDay = 2;
var totalNeeded = (numPerDay * 365) * (maxAge - age);
var message = 'You will need ' + totalNeeded + ' cups of tea to last you until the ripe old age of ' + maxAge;
console.log(message);