-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
44 lines (33 loc) · 1.14 KB
/
Copy pathmain.js
File metadata and controls
44 lines (33 loc) · 1.14 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
const fs = require("fs")
document.addEventListener("DOMContentLoaded", (event) => {
console.log("DOM loaded")
initApp()
})
const initApp = () => {
let data = readListingInfo()
data = csvmaker(data)
addToCSV(data)
}
const readListingInfo = () => {
const name = document.getElementById('input-name').value
const price = document.getElementById('input-price').value
const description = document.getElementById('input-description').value
const condition = document.getElementById('input-condition').value
const brand = document.getElementById('input-brand').value
const contactInfo = document.getElementById('input-contact-info').value
const myObj = {
name: "name", price: "20", description: "description", condition: "condition", brand: "brand", contactInfo: "954-997-0952"
}
return myObj
}
const csvmaker = (info) => {
csvRows = []
const headers = Object.keys(info)
csvRows.push(headers.join(','))
const values = Object.values(info).join(',');
csvRows.push(values)
// Returning the array joining with new line
return csvRows.join('\n')
}
const addToCSV = () => {
}