Skip to content

Instantly share code, notes, and snippets.

@ancw24
Created September 21, 2018 13:03
Show Gist options
  • Select an option

  • Save ancw24/f7e038415ae5ec7d720b1e9e427fbcdc to your computer and use it in GitHub Desktop.

Select an option

Save ancw24/f7e038415ae5ec7d720b1e9e427fbcdc to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yuhevum
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
'use strict';
var add = function add(num1, num2, num3) {
return num1 + num2 + num3;
};
console.log(add(2, 4, 6));
console.log(add(3, 12, 34));
var multiply = function multiply(num1, num2, num3) {
return num1 * num2 * num3;
};
console.log(multiply(3, 5, 8));
var square = function square(num) {
return Math.pow(num, 2);
};
console.log(square(7));
console.log(square(4));
var division = function division(num1, num2) {
return num2 / num1;
};
console.log(division(7, 21));
var sayHi = function sayHi() {
return console.log('Hi there ' + square(2) + ' + ' + multiply(2, 5, 3) + ' + ' + add(3, 2, 5) + ' + ' + division(3, 9));
};
sayHi();
var tellFortune = function tellFortune(numberOfChildren, partnersName, geographicLocation, jobTitle, houseSize) {
return console.log('You will be happy married with the ' + partnersName + ' having ' + numberOfChildren + ' lovely children , leaving in ' + geographicLocation + ' in a ' + houseSize + ' square meeters big house and happy working as a ' + jobTitle);
};
tellFortune(3, 'Mark', 'Berlin', 'Freelancer', 250);
tellFortune(4, 'Nikolas', 'Buenos Aires', 'Sailor', 300);
tellFortune(2, 'Mike', 'London', 'My own boss', 400);
var calculateAge4 = function calculateAge4(animal, ageOfAnimal) {
if (animal === 'dog') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 7 + ' human years old');
} else if (animal === 'cow') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 14 + ' human years old');
} else if (animal === 'chinchilla') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 25 + ' human years old');
} else {
console.log('it is not a dog, cow or chinchilla. Wrong Input!');
}
};
calculateAge4('dog', 5);
calculateAge4('cow', 7);
calculateAge4('chinchilla', 3);
calculateAge4('elephant', 12);
</script>
<script id="jsbin-source-javascript" type="text/javascript">let add = (num1, num2, num3)=> num1 + num2 + num3;
console.log(add(2,4,6));
console.log(add(3,12,34));
let multiply = (num1, num2, num3) => num1 * num2 * num3;
console.log(multiply(3,5,8));
let square =(num) => num **2;
console.log(square(7));
console.log(square(4));
let division = (num1,num2) => num2/ num1;
console.log(division(7,21));
let sayHi = () => console.log(`Hi there ${square (2)} + ${multiply(2,5,3)} + ${add(3,2,5)} + ${division(3,9)}`);
sayHi();
let tellFortune = (numberOfChildren,partnersName,geographicLocation,jobTitle,houseSize) =>
console.log(`You will be happy married with the ${partnersName} having ${numberOfChildren} lovely children , leaving in ${geographicLocation} in a ${houseSize} square meeters big house and happy working as a ${jobTitle}`);
tellFortune(3, 'Mark', 'Berlin', 'Freelancer', 250);
tellFortune(4,'Nikolas', 'Buenos Aires', 'Sailor',300);
tellFortune(2,'Mike','London','My own boss', 400);
let calculateAge4 = (animal,ageOfAnimal) => {
if ( animal === 'dog'){
console.log(`Your ${animal} is ${ageOfAnimal *7} human years old`);
} else if ( animal === 'cow' ){
console.log(`Your ${animal} is ${ageOfAnimal * 14} human years old` );
} else if ( animal ==='chinchilla'){
console.log(`Your ${animal} is ${ageOfAnimal * 25} human years old`);
} else {
console.log(`it is not a dog, cow or chinchilla. Wrong Input!`);
}
};
calculateAge4('dog',5);
calculateAge4('cow',7);
calculateAge4('chinchilla',3);
calculateAge4('elephant',12);
</script></body>
</html>
'use strict';
var add = function add(num1, num2, num3) {
return num1 + num2 + num3;
};
console.log(add(2, 4, 6));
console.log(add(3, 12, 34));
var multiply = function multiply(num1, num2, num3) {
return num1 * num2 * num3;
};
console.log(multiply(3, 5, 8));
var square = function square(num) {
return Math.pow(num, 2);
};
console.log(square(7));
console.log(square(4));
var division = function division(num1, num2) {
return num2 / num1;
};
console.log(division(7, 21));
var sayHi = function sayHi() {
return console.log('Hi there ' + square(2) + ' + ' + multiply(2, 5, 3) + ' + ' + add(3, 2, 5) + ' + ' + division(3, 9));
};
sayHi();
var tellFortune = function tellFortune(numberOfChildren, partnersName, geographicLocation, jobTitle, houseSize) {
return console.log('You will be happy married with the ' + partnersName + ' having ' + numberOfChildren + ' lovely children , leaving in ' + geographicLocation + ' in a ' + houseSize + ' square meeters big house and happy working as a ' + jobTitle);
};
tellFortune(3, 'Mark', 'Berlin', 'Freelancer', 250);
tellFortune(4, 'Nikolas', 'Buenos Aires', 'Sailor', 300);
tellFortune(2, 'Mike', 'London', 'My own boss', 400);
var calculateAge4 = function calculateAge4(animal, ageOfAnimal) {
if (animal === 'dog') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 7 + ' human years old');
} else if (animal === 'cow') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 14 + ' human years old');
} else if (animal === 'chinchilla') {
console.log('Your ' + animal + ' is ' + ageOfAnimal * 25 + ' human years old');
} else {
console.log('it is not a dog, cow or chinchilla. Wrong Input!');
}
};
calculateAge4('dog', 5);
calculateAge4('cow', 7);
calculateAge4('chinchilla', 3);
calculateAge4('elephant', 12);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment