1//Our number.
2var number = 120;
3
4//The percent that we want to get.
5//i.e. We want to get 50% of 120.
6var percentToGet = 50;
7
8//Calculate the percent.
9var percent = (percentToGet / 100) * number;
10
11//Alert it out for demonstration purposes.
12alert(percentToGet + "% of " + number + " is " + percent);
13
14//The result: 50% of 120 is 60
15