Repository navigation
Expand file tree
/
Copy pathchallenge.js
More file actions
97 lines (72 loc) · 2.21 KB
/
Copy pathchallenge.js
File metadata and controls
97 lines (72 loc) · 2.21 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// arr1 = [1,2,3,5];
// arr2 = [4,8,9,10];
// // Take 2 lists, add together, put in order and return in order
// function combineLists(list1,list2) {
// combined = [];
// // gather the lists
// const list1 = arr1.length;
// const list2 = arr2.length;
// // add them togther
// // put them in order
// // return
// }
// Palidrome
// split().reverse().join()
// -----------------------------------------------------------------------------------------------
// Create a function to take a list of integers, function should return sum of all number in list
// const arr = [1,2,3]
// return = 6
// function listSum(aList) {
// // loop through array
// // grab numbers and add
// // created a sum holder variable to equal zero **remember to create holder variable
// let sum =0;
// // for loop iterates through each element and add it to the sum variable
// for(let i =0; i< aList.length; i++) {
// sum += aList[i];
// }
// // return the sum
// return sum
// }
// const arr = [1,2,3]
// // const result = listSum(arr)
// console.log(listSum(arr));
// ---------------------------------------------------------------------------------------------------
// create a function that takes array in returns the first element
// arr = [1,2,3]
// results 1
// function firstElement(para) {
// // get first element index [0]
// return para[para.length-1];
// }
// arr = [1,2,3]
// console.log(firstElement(arr))
// -------------------------------------------------------------------------------------------------
// Convert roman to int
// make a const key value object
// Symbol Value
// I 1
// V 5
// X 10
// L 50
// C 100
// D 500
// M 1000
// holder variable to take inter
// loop through list
// if number is less than the number next to it, it must subtract
// var romanToInt = function(s) {
// const vals = {
// 'I': 1,
// 'V': 5,
// 'X': 10,
// 'L': 50,
// 'C': 100,
// 'D': 500,
// 'M': 1000,
// }
// let num = 0;
// for (let i =0; i <= s.length; i++) {
// if (vals[s[1]])
// }
// };