Skip to content

Commit 57cdc81

Browse files
committed
Function #31: added
1 parent 20a4a5e commit 57cdc81

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

Problem.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#28: Create a function that will return in an array. becarefull function parameter and array length is same in count.
2929
#29: Create a function that takes the age in years and returns the age in days.
3030
#30: Create a function that takes voltage and current and returns the calculated power.
31+
#31: Given two numbers, return true if the sum of both numbers is less than 50. Otherwise return false.
3132

3233

3334

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,3 +428,28 @@ const circuitPower = (voltage, current) => voltage * current;
428428
console.log(circuitPower(115, 5));
429429
430430
```
431+
432+
**#31: Given two numbers, return true if the sum of both numbers is less than 50. Otherwise return false.**
433+
434+
```
435+
436+
function lessThan50(a, b) {
437+
if (a + b < 50) {
438+
return true;
439+
} else {
440+
return false;
441+
}
442+
}
443+
console.log(lessThan50(40, 30));
444+
445+
```
446+
447+
**// Or ShortCut**
448+
449+
```
450+
451+
const lessThan50 = (a, b) => a + b < 50;
452+
console.log(lessThan50(30.15));
453+
454+
``
455+
```

script.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ const str = "Md Nazmul islam";
233233
const newStr = str.split("").reverse().join("");
234234
console.log(newStr);
235235
236-
237236
// #27: Create a function that takes an array and returns the types of values (data types) in a new array.
238237
239238
const arrayValuesTypes = (arr) => {
@@ -250,7 +249,6 @@ console.log(arrayValuesTypes([1, 2, "Nazmul", [], true]));
250249
const arrayValuesTypes = (arr) => arr.map((x) => typeof x);
251250
console.log(arrayValuesTypes([1, 2, "Nazmul", [], true]));
252251
253-
254252
// #28: Create a function that will return in an array. becarefull function parameter and array length is same in count.
255253
function getArray(number) {
256254
var newArray = [];
@@ -270,8 +268,22 @@ console.log(getArray(5));
270268
const calcAge = (age) => (age < 0 || typeof age != "number" ? null : age * 365);
271269
console.log(calcAge(5));
272270
273-
*/
274-
275271
// #30: Create a function that takes voltage and current and returns the calculated power.
276272
const circuitPower = (voltage, current) => voltage * current;
277273
console.log(circuitPower(115, 5));
274+
275+
// #31: Given two numbers, return true if the sum of both numbers is less than 50. Otherwise return false.
276+
function lessThan50(a, b) {
277+
if (a + b < 50) {
278+
return true;
279+
} else {
280+
return false;
281+
}
282+
}
283+
console.log(lessThan50(40, 30));
284+
285+
// Or ShortCut
286+
const lessThan50 = (a, b) => a + b < 50;
287+
console.log(lessThan50(30.15));
288+
289+
*/

0 commit comments

Comments
 (0)