JavaScript Challenges
How Edabit Works
This is an introduction to how challenges on Edabit work. In the Code tab above you'll see a starter function that looks like this: function hello() { } All you have to do is type return "hello edabit.com" between the curly braces { } and then click the Check button. If you did this correctly, the button will turn red and say SUBMIT FINAL. Click it and seeReturn the Sum of Two Numbers
Create a function that takes two numbers as arguments and returns their sum. Examples addition(3, 2) ➞ 5 addition(-3, -6) ➞ -9 addition(7, 3) ➞ 10 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Convert Minutes into Seconds
Write a function that takes an integer minutes and converts it to seconds. Examples convert(5) ➞ 300 convert(3) ➞ 180 convert(2) ➞ 120 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Return the Next Number from the Integer Passed
Create a function that takes a number as an argument, increments the number by +1 and returns the result. Examples addition(0) ➞ 1 addition(9) ➞ 10 addition(-3) ➞ -2 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the Solutions tab.Area of a Triangle
Write a function that takes the base and height of a triangle and return its area. Examples triArea(3, 2) ➞ 3 triArea(7, 4) ➞ 14 triArea(10, 10) ➞ 50 Notes The area of a triangle is: (base * height) / 2 Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you're really stuck, unlock solutions in the SolutioConvert Age to Days
Create a function that takes the age in years and returns the age in days. Examples calcAge(65) ➞ 23725 calcAge(0) ➞ 0 calcAge(20) ➞ 7300 Notes Use 365 days as the length of a year for this challenge. Ignore leap years and days between last birthday and now. Expect only non-negative integer inputs.Buggy Code (Part 1)
Fix the code in the code tab to pass this challenge (only syntax errors). Look at the examples below to get an idea of what the function should do. Examples cubes(3) ➞ 27 cubes(5) ➞ 125 cubes(10) ➞ 1000 Notes READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER! Don't overthink this challenge; it's not supposed to be hard.Return the First Element in an Array
Create a function that takes an array containing only numbers and return the first element. Examples getFirstValue([1, 2, 3]) ➞ 1 getFirstValue([80, 5, 100]) ➞ 80 getFirstValue([-500, 0, 50]) ➞ -500 Notes The first element in an array always has an index of 0.Power Calculator
Create a function that takes voltage and current and returns the calculated power. Examples circuitPower(230, 10) ➞ 2300 circuitPower(110, 3) ➞ 330 circuitPower(480, 20) ➞ 9600 Notes power is voltage multiplied by current.Convert Hours into Seconds
Write a function that converts hours into seconds. Examples howManySeconds(2) ➞ 7200 howManySeconds(10) ➞ 36000 howManySeconds(24) ➞ 86400 Notes 60 seconds in a minute, 60 minutes in an hour Don't forget to return your answer.Maximum Edge of a Triangle
Create a function that finds the maximum range of a triangle's third edge, where the side lengths are all integers. Examples nextEdge(8, 10) ➞ 17 nextEdge(5, 7) ➞ 11 nextEdge(9, 2) ➞ 10 Notes (side1 + side2) - 1 = maximum range of third edge. The side lengths of the triangle are positive integers. Don't forget to return the result.Return the Remainder from Two Numbers
There is a single operator in JavaScript, capable of providing the remainder of a division operation. Two numbers are passed as parameters. The first parameter divided by the second parameter will have a remainder, possibly zero. Return that value. Examples remainder(1, 3) ➞ 1 remainder(3, 4) ➞ 3 remainder(-9, 45) ➞ -9 remainder(5, 5) ➞ 0 Notes The testsFind the Perimeter of a Rectangle
Create a function that takes length and width and finds the perimeter of a rectangle. Examples findPerimeter(6, 7) ➞ 26 findPerimeter(20, 10) ➞ 60 findPerimeter(2, 9) ➞ 22 Notes Don't forget to return the result. If you're stuck, find help in the Resources tab. If you're really stuck, find solutions in the Solutions tab.Return Something to Me!
Write a function that returns the string "something" joined with a space " " and the given argument a. Examples giveMeSomething("is better than nothing") ➞ "something is better than nothing" giveMeSomething("Bob Jane") ➞ "something Bob Jane" giveMeSomething("something") ➞ "something something" Notes Assume an input is given.Correct the Mistakes
Fix the code in the code tab to pass this challenge. Look at the examples below to get an idea of what the function should do. Examples squared(5) ➞ 25 squared(9) ➞ 81 squared(100) ➞ 10000 Notes READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER! Don't overthink this challenge; it's not supposed to be hard.Is the Number Less than or Equal to Zero?
Create a function that takes a number as its only argument and returns true if it's less than or equal to zero, otherwise return false. Examples lessThanOrEqualToZero(5) ➞ false lessThanOrEqualToZero(0) ➞ true lessThanOrEqualToZero(-2) ➞ true Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab. If you'reSum of Polygon Angles
Given an n-sided regular polygon n, return the total sum of internal angles (in degrees). Examples sumPolygon(3) ➞ 180 sumPolygon(4) ➞ 360 sumPolygon(6) ➞ 720 Notes n will always be greater than 2. The formula (n - 2) x 180 gives the sum of all the measures of the angles of an n-sided polygon.Basketball Points
You are counting points for a basketball game, given the amount of 2-pointers scored and 3-pointers scored, find the final points for the team and return that value. Examples points(1, 1) ➞ 5 points(7, 5) ➞ 29 points(38, 8) ➞ 100 Notes N/ABasic Variable Assignment
A student learning JavaScript was trying to make a function. His code should concatenate a passed string name with string "Edabit" and stores it in a variable called result. He needs your help to fix this code. Examples nameString("Mubashir") ➞ "MubashirEdabit" nameString("Matt") ➞ "MattEdabit" nameString("javaScript") ➞ "javaScriptEdabit" Notes Don't forgLess Than 100?
Given two numbers, return true if the sum of both numbers is less than 100. Otherwise return false. Examples lessThan100(22, 15) ➞ true // 22 + 15 = 37 lessThan100(83, 34) ➞ false // 83 + 34 = 117 lessThan100(3, 77) ➞ true Notes N/A