//Данная функция реверсит массив методом, схожим на метод сортировки пузырьком
function reverseArrayInPlace(array) {
//пока не дойдем до середины массива
for (let i = 0; i < Math.floor(array.length / 2); i++) {
i-тый элемент массива(идем с 1го элемента) записывает в временную переменную
let old = array[i];
в i-тый элемент массива записываем значение i-того элемента с конца массива (при i = 0, самый последний массив, и т.д.)
array[i] = array[array.length - 1 - i];
//в вышесказанный элемент массива с его конца записываем значение i-того элемента массива (который мы во временную переменную записали
array[array.length - 1 - i] = old;
}
//в итоге мы за O(n/2) ходов реверснули массив и возвращаем его
return array;
}
let arrayValue = [1, 2, 3, 4, 5];
reverseArrayInPlace(arrayValue);
console.log(arrayValue);
window.onload = function() {
document.querySelector('.block').addEventListener('click', event => {
console.log(event);
if (event.target.className == 'item'){
var dataTab = event.target.getAttribute('data-tab');
var tabH = document.getElementsByClassName('items');
for (var i=0; i < tabH.length; i++){
tabH[i].classList.remove('active');
}
event.target.classList.add('active');
var tabBody = document.getElementsByClassName('content');
for (var i=0; i < tabBody.length; i++) {
if (dataTab == i) {
tabBody[i].style.display = 'block';
}
}
}
}
}
})
https://jsfiddle.net/md1wrvt3/3/
To fix the dependency tree, try following the steps below in the exact order:
1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.
In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:
5. If you used npm, install yarn (yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.
6. Check if C:\Users\Алексей\node_modules\webpack is outside your project directory.
For example, you might have accidentally installed something in your home folder.
7. Try running npm ls webpack in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed webpack.
If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
rand.length -= 3;