Skip to content

JSDR213/functions_lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 

Repository files navigation

Functions Exercise:

  1. We are looking to re-sod our lawn. It has a length of 25' and a width of 30', with Sod costing $1.45/sqft. Additionally, it will cost $180 to have the work done. Write a function that finds the area of the lawn, the price of the Sod needed, and what the total cost will be to get the lawn redone. Our budget is $1,100; set a conditional that sees if the cost is higher or lower than our budget, and by how much either way.

  2. Overtime Calculator: A local business pays $25/hr for the first 40 hours worked each week, and time-and-a-half for each hour worked after that. Using your conditionals and mathematic operators, create a function that tells us how much someone would make if they worked 35hrs in a week, and how much if they worked 45hrs.

  3. Century From Year: the first century goes from the year 1 to the year 99, the 19th century went from the year 1801 to 1900, and the 20th century strecthed from 1901 to the year 2000. Using our Math functions, write a function that takes a year as an argument, and logs which century it is in

  4. Palindrome tester! Create a function that accepts a string as an argument. Using our String Methods and Conditonals, create a function to test whether or not the string is a Palindrome. After that - 'Go hang a salami, Im a lasagna hog'

  5. Write a function that loops over the following array of SEI students and prints out their name, and how many letters their name is, as long as the name is 4 or more letters long. (you can copy this array into your code, don't worry about re-writing it)

const students = [
  'Alice',
  'Andrew',
  'Bartholemew',
  'Casey',
  'Damian',
  'Grant',
  'Howie',
  'Wade',
  'Kat',
  'Kim',
  'Kiu',
  'Natasha',
  'Obi',
  'Pedro',
  'Sarah',
  'Scott',
  'Tiffany',
  'Zhe'
]

It should give us "Alice is 5 letters long"... and so on

  1. E-Commerce Mock-up : Create an array of objects for sale in an e-commerce site. Each object should have a property of name, price, whether the item is in stock or not, and a rating of 1-5. Then create a function that will loop through this array and only log the items that are instock, with either a price lower than, and a rating higher than, two values that you pass in as arguments.

  2. A Realtor has contracted you to find the mean value of houses in an area. The values are as follows. Create a function that finds the average, and is versatile enough to perform the task if any houses are added, or removed to the data.

const houseValues = [800000, 750000, 1200000, 675000, 1000000, 880000, 1300500, 975000, 780000, 1305000, 9000000]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published