function calculateTotalPrice(items) { let total = 0; items.forEach((item) => { total += Number(item.price); // Number parsen }); return Number(total.toFixed(2)); } const shoppingCart = [ { name: 'Laptop', price: 999.99 }, { name: 'Smartphone', price: 599.99 }, // string zu zahl { name: 'Headphones', price: 199.99 }, // cost -> price ]; const totalPrice = calculateTotalPrice(shoppingCart); console.log('Total Price:', Number(totalPrice).toFixed(2)); function displayUserProfile(user) { console.log(`Name: ${user.name}`); console.log(`Age: ${user.age}`); console.log(`Email: ${user.email.toLowerCase()}`); } const userProfile = { name: 'Sarah', age: 'twenty-five', email: 'SARAH@EXAMPLE.COM', }; displayUserProfile(userProfile); function getFirstItemName(items) { return items[0].name.toUpperCase(); } console.log('First Item:', getFirstItemName(shoppingCart)); // => LAPTOP const numberList = '1,2,3,4,5'; const sum = numberList.split(',').reduce((acc, num) => acc + Number(num), 0); //mit split zu einem arr console.log('Sum:', sum); // => 15