This commit is contained in:
@@ -27,9 +27,9 @@
|
||||
const convertCsvToObj = (csv = '') => {
|
||||
const rows = csv.split('\n'); // => ['name, category, price', 'Klingon Letter Opener, Office Warfare, 19.99',...]
|
||||
|
||||
const headerRow = rows.shift().split(/\s*,\s*/);
|
||||
const headerFields = rows.shift().split(/\s*,\s*/);
|
||||
|
||||
console.log(headerRow); // => ['name', 'category', 'price']
|
||||
console.log(headerFields); // => ['name', 'category', 'price']
|
||||
|
||||
const productRows = rows
|
||||
.map((row) => row.trim()) // "white spaces" der Strings werden entfernt
|
||||
@@ -60,7 +60,8 @@
|
||||
const products = convertCsvToObj(productsCsv);
|
||||
|
||||
// output
|
||||
console.log(products);
|
||||
console.log(JSON.stringify(products, null, 2)); // JSON String
|
||||
console.log(products); // Produkte Array
|
||||
|
||||
outputEl.innerHTML = `<ol>${products
|
||||
.map((product) => {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
const calcFactorialWithWhile = () => {};
|
||||
|
||||
// Test cases
|
||||
console.log(calcFactorial(5)); // => 120
|
||||
console.log(calcFactorial(5)); // => 5! = 5 * 4 * 3 * 2 * 1 = 120
|
||||
console.log(calcFactorial(3)); // => 6
|
||||
console.log(calcFactorial(0)); // => 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user