@cheshireoctopus/

Intro Function Arguments

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.15308397374117666","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"LyoKICAxLiBXcml0ZSBhIGZ1bmN0aW9uLCBmYXZvcml0ZUFuaW1hbCwgdGhhdCBhY2NlcHRzIGFuIGFuaW1hbCBhcyBhbiBhcmd1bWVudCBhbmQgY29uc29sZS5sb2cncyBzb21ldGhpbmcgc2ltaWxhciB0bzogIkkgbGlrZSA8QU5JTUFMPiEiCiAgRXg6IGZhdm9yaXRlQW5pbWFsKCdjYXRzJykgc2hvdWxkIGNvbnNvbGUubG9nICJJIGxpa2UgY2F0cyEiCiovCmZ1bmN0aW9uIGZhdm9yaXRlQW5pbWFsKGFuaW1hbCkgewogIGNvbnNvbGUubG9nKCdJIGxpa2UgJyArIGFuaW1hbCkKfQoKZmF2b3JpdGVBbmltYWwoJ29jdG9wdXMnKQoKLyoKICAyLiBXcml0ZSBhIGZ1bmN0aW9uLCBkb3VibGUsIHRoYXQgdGFrZXMgYSBudW1iZXIgYW5kIGRvdWJsZXMgaXQgCiAgRXg6IGRvdWJsZSgzKSBzaG91bGQgY29uc29sZS5sb2cgNgoqLwpmdW5jdGlvbiBkb3VibGUobnVtYmVyKSB7CiAgY29uc29sZS5sb2cobnVtYmVyICogMikKfQoKZG91YmxlKDUpCgovKgogIDMuIFdyaXRlIGEgZnVuY3Rpb24sIHN1bSwgdGhhdCB0YWtlcyB0d28gbnVtYmVycyBhbmQgbG9ncyB0aGVpciBzdW0KICBFeDogc3VtKDQsIDUpIHNob3VsZCBjb25zb2xlLmxvZyA5CiovCmZ1bmN0aW9uIHN1bSh4LCB5KSB7CiAgY29uc29sZS5sb2coeCArIHkpCn0KCnN1bSg0LCA1KQoKCi8qCiAgNC4gV3JpdGUgYSBmdW5jdGlvbiwgYXJlYU9mVHJpYW5nbGUsIHRoYXQgY2FsY3VsYXRlcyB0a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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
  1. Write a function, favoriteAnimal, that accepts an animal as an argument and console.log's something similar to: "I like <ANIMAL>!"
  Ex: favoriteAnimal('cats') should console.log "I like cats!"
*/
function favoriteAnimal(animal) {
  console.log('I like ' + animal)
}

favoriteAnimal('octopus')

/*
  2. Write a function, double, that takes a number and doubles it 
  Ex: double(3) should console.log 6
*/
function double(number) {
  console.log(number * 2)
}

double(5)

/*
  3. Write a function, sum, that takes two numbers and logs their sum
  Ex: sum(4, 5) should console.log 9
*/
function sum(x, y) {
  console.log(x + y)
}

sum(4, 5)


/*
  4. Write a function, areaOfTriangle, that calculates the area of a triangle given its base and height. Hint: the area of a traingle is 1/2 * base * height
  Ex: areaOfTriangle(4, 2) should console.log 4
*/
function areaOfTriangle(base, height) {
  console.log(base * height * 1/2)
}

areaOfTriangle(4, 10)

/*
  5. Write a function, areaOfCircle, that calculates the area of a cirlce given its radius. 
  Hint: the area of a circle is πr^2.
  Another Hint: Use Math.PI to get an approximate value of PI
  
  Ex: areaOfCircle(5) should console.log 78.53981633974483
  Challenge: round the logged value to two decimal places
*/

function areaOfCircle(radius) {
  var area = Math.PI * Math.pow(radius, 2)
  console.log(Math.round(area))
}

areaOfCircle(5)















Native Browser JavaScript