Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/ Please write your code directly below the corresponding numbers. // #1 var ful

ID: 3887104 • Letter: #

Question

/ Please write your code directly below the corresponding numbers.

// #1 var fullName = 'Linus Torvalds';

var birthYear = 1969;

// #2 var myArray = [];

// #3 myArray.push(fullName, birthYear); console.log(myArray);

// #4 var splitName = ((fullName.split)(" "));

console.log(splitName);

// #5 function sayHello()

{} console.log('Hello,' + fullName[0] + '!');

// #6 function calcAge(present)

{ return (present - birthYear);

}

console.log(calcAge(2017));

I need help with question 6.Giving an error .6.Write another function called calcAge. This function should take one parameter, a year, and it should return the implied age of Linus Torvalds. Call the function passing the current year as the parameter.

Explanation / Answer

<!DOCTYPE html>
<html>
<body>
<script>
var fullName = 'Linus Torvalds';
var birthYear = 1969;
var myArray = [];
myArray.push(fullName, birthYear); console.log(myArray);
var splitName = ((fullName.split)(" "));
console.log(splitName);
function sayHello()
{ console.log('Hello,' + fullName[0] + '!');
}
function calcAge(present)
{ return (present - birthYear);
}
console.log(calcAge(2017));
</script>
</body>
</html>

Output:

Linus,Torvalds

48