Write a function that takes an array of at least three elements and returns an object with properties first, second, and rest (an array of the remaining elements). Use array destructuring.
function splitArray(arr) {
}
console.log(splitArray([1, 2, 3, 4, 5]));
Write a function that takes a user object (with name, age, and email properties) and returns a greeting string using only the name and age. Use object destructuring in the function parameters.
function greetUser({ name, age }) {
}
console.log(greetUser({ name: "Alice", age: 30, email: "[email protected]" }));
Solution
function greetUser({ name, age }) {
return `Hello, ${name}! You are ${age} years old.`;
}
console.log(greetUser({ name: "Alice", age: 30, email: "[email protected]" }));
Write a function that takes two objects and returns a new object that contains all properties from both. If a property exists in both, the second object's value should win. Use the spread operator.
Write a function that takes a user object and a new name, and returns a new object that is a copy of the user with the name updated. Do not modify the original. Use the spread operator.
Write a function that takes a config object and returns a settings object with defaults applied. Use destructuring with default values: theme defaults to 'light', fontSize to 16, and language to 'en'.
Write a function that takes an array of numbers and returns the largest one, using Math.max() with the spread operator (Math.max does not accept an array directly).
Write a function that takes a product object (with 'name' and 'price' properties) and returns a new object with the properties renamed to 'title' and 'cost'. Use destructuring with renaming.
function renameProduct(product) {
}
console.log(renameProduct({ name: "Widget", price: 9.99 }));
We use necessary cookies to run the site. With your permission, we can also save your site preferences and use analytics and advertising cookies to understand usage and support the project.
Open tools in tabs.Exercises, IDE tools, and trainers stay available as site tabs.
Switch without losing context.Move between explanations, code, and utilities while keeping your place.
Use the sidebar as your map.The left panels hold navigation, settings, files, libraries, and tool controls.
PythonJavaScriptSQLite
One IDE, three practical modes
Python in the browser.Run small scripts, try libraries, and practice API requests without installing anything.
JavaScript for quick experiments.Test browser-friendly code and compare ideas next to your learning materials.
SQLite for data practice.Open the database explorer to inspect tables, write queries, and learn SQL workflows locally.
TopicIDE
Work side by side with split tabs
Keep instructions visible.Open an exercise or reference page beside the IDE instead of jumping back and forth.
Compare tools while you learn.Place regex checks, explanations, and code experiments next to each other when the task needs it.
Close the split when you are done.The workspace returns to a single focused tab, and your open site tabs remain available.
Code Typing Trainer
Or plain text
This trainer is designed for a physical keyboard.Open this section on a laptop or desktop with a wide screen. Touch typing practice will not work correctly on a phone.
Speed: 0 chars/min
0 words/min
Best speed (60s): 0 chars/min
0 words/min
Errors: 0
Total time: 0.0 s
To practice touch typing, avoid looking at your physical keyboard.