|
- function replaceChildren(element, newChildren) {
- removeChildren(element);
- addChildren(element, newChildren);
- }
-
- function addChildren(element, children) {
- for (let child of children) {
- element.appendChild(child);
- }
- }
-
- function removeChildren(element) {
- while (element.lastChild) {
- element.removeChild(element.lastChild);
- }
- }
-
- function round(val, places = 0) {
- return Math.round(val * Math.pow(10, places)) / Math.pow(10, places);
- }
|