-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2023-12-23 Codewars 8 Kyu Fundamentals - Training JS #2 Basic data types--Number.js
68 lines (51 loc) · 1.79 KB
/
2023-12-23 Codewars 8 Kyu Fundamentals - Training JS #2 Basic data types--Number.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
// 12/23/23 Saturday Codewars 8 Kyu Fundamentals - Training JS #2: Basic data types--Number
// https://www.codewars.com/kata/571edd157e8954bab500032d/train/javascript
/*
In javascript, Number is one of basic data types. It can be positive: 1,2,3, negative:-1,-100 , integer:123,456, decimal:3.1415926,-8.88 etc..
Numbers can use operators such as + - * / %
Task
I've written five function equal1,equal2,equal3,equal4,equal5, defines six global variables v1 v2 v3 v4 v5 v6, every function has two local variables a,b, please set the appropriate value for the two variables(select from v1--v6), making these function return value equal to 100. the function equal1 is completed, please refer to this example to complete the following functions.
When you have finished the work, click "Run Tests" to see if your code is working properly.
In the end, click "Submit" to submit your code pass this kata.
*/
let v1 = 50,
v2 = 100,
v3 = 150,
v4 = 200,
v5 = 2,
v6 = 250;
function equal1(){
let a = v1,
b = v1;
return a + b;
}
//Please refer to the example above to complete the following functions
function equal2(){
let a = v3, //set number value to a
b = v1; //set number value to b
return a - b;
}
function equal3(){
let a = v1, //set number value to a
b = v5; //set number value to b
return a * b;
}
function equal4(){
let a = v4, //set number value to a
b = v5; //set number value to b
return a / b;
}
function equal5(){
let a = v6, //set number value to a
b = v3; //set number value to b
return a % b;
}
/* =============
Other Solutions
============= */
var v1=50;v2=100,v3=150,v4=200,v5=2,v6=250
const equal1 = () => v1 + v1
const equal2 = () => v3 - v1
const equal3 = () => v1 * v5
const equal4 = () => v4 / v5
const equal5 = () => v6 % v3