Hier zijn de oplossingen van de 15 opgaven die ik heb gemaakt.
Ik ben niet echt tegen problemen aangelopen en ik hoefde niet 1x te cheaten!
- How Edabit works
function returnTrue() {
return true;
}
2. Return the sum of 2 numbers
function addition($a, $b) {
Return $a + $b;
}
3. Return the next number
function addition($num) {
return $num +1;
}
4. Convert minutes into seconds
function convert($minutes) {
return $minutes * 60;}
5. Return something to me!
function giveMeSomething($a) {
Return "something ". $a;
}
6. Area of a triangle
function triArea($base, $height) {
return $base * $height / 2;
}
7. Maximum edge of a triangle
function triArea($base, $height) {
return $base * $height / 2;
}
8. Convert age to days
function calcAge($age) {
return $age/365;
}
9. LesserThanOrEqualToZero
function lessThanOrEqualToZero($num) {
if($num > 0){ return false;} else {return true;}
}
10. Return first element in an array
function getFirstValue($array) {
return $array[0];
}
11. The && operator
function andCompare($a, $b) {
if ($a && $b){return true;}else{return false;}
}
13. FPS
function frames($minutes, $fps) {
return $fps * 60 * $minutes;
}
14.Perimeter of a rectangle
function findPerimeter($length, $width) {
return 2 * $length + 2 * $width;
}
15. Convert hours and minutes into seconds
function convert($hours, $minutes) {
return $hours * 3600 + $minutes * 60;
}