-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfinda.js
More file actions
100 lines (100 loc) · 2.72 KB
/
finda.js
File metadata and controls
100 lines (100 loc) · 2.72 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
96
97
98
99
100
// // Using the language of your choice, write a function that takes as input a JSON string
// // representing an array of objects,and returns a description of the data format.
// // Write one or more new test inputs. Provide the function, the test inputs,
// // and the corresponding test outputs.
//
// // SAMPLE INPUT
// const input = [{
// name: 'Douglas Crawford',
// salary: 80000,
// address: {
// line1: 'c/o Unstructured Programmers Anonymous',
// line2: '7723 Western Avenue',
// city: 'San Francisco',
// state: 'CA',
// zip: '9123',
// },
// },
// {
// name: 'Brian Kernighan',
// salary: 60000,
// address: {
// line1: 'PO BOX 455',
// city: 'Princeton',
// state: 'NJ',
// zip: '08544',
// },
// }];
//
//
//
// const address = {};
// address.attribute = [];
// address.attribute[0] = {};
// address.attribute[0].line="contenttype";
// address.attribute[0].city="Content type";
// address.attribute[0].state = {};
//
// console.log(address);
//
//
// /*
// TODO
// */
// //
// //
// // const inputToJson = JSON.stringify(input);
// // const inputToJsonSplit = inputToJson.split(',');
// // const convertFunc = (inputToJsonSplit) => {
// // if (inputToJsonSplit.indexOf('[{' && ']}' )) {
// // return 1;
// // }
// // }
// // // console.log(typeof inputToJson)
// // console.log(inputToJsonSplit);
// // // const inputToJson = (input) => {
// // //
// // // }
// // console.log(convertFunc(inputToJson));
// // console.log(inputToJson);
//
// // SAMPLE OUTPUT (you choose the format.
// // This implementer chose to use TypeScript's interface format, augmenting with comments.)
//
// // interface inferredJSONFormat {
// // name: string,
// // salary: number,
// // address: IAddress,
// // }
// // interface IAddress {
// // line1: string,
// // line2?: string,
// // city: string,
// // state: string, // 2 characters
// // zip: string, // nu
//
// //
// // /*
// // TODO stringify
// // 1. name, salary 만 타입 검사를 해보자
// // 2. 리턴할 때는, key: type 으로 나와야한다
// // 3. key를 따로 지정할 수 있을까?
// // 4. 어떤식으로 json파일을 분류할 수있을까
// // */
// // const inputToJson = JSON.stringify(input);
// // // const pureInputToJson = inputToJson.replace(/\"/g,'');
// // const inputToJsonArray = pureInputToJson.split(',');
// //
// // let result = 0;
// //
// // for (let i = 0; i < inputToJsonArray.length; i += 1) {
// // const checkString = 'z';
// // if (inputToJsonArray[i].indexOf(checkString)) {
// // result += 1;
// // }
// // }
// //
// // console.log(pureInputToJson);
// // console.log(result);
// // console.log(inputToJson);
// // console.log(inputToJsonArray[3]);