alena0309, всё работает:
<script>
let userJsonURL = 'users.json';
let users = [];
let nameFilter = `name`;
const nameFilterUpper = nameFilter.toUpperCase();
const wrapItemNameInSpan = (item) => `<span class="name">${item.name}</span>`;
const render = () => {
document.body.innerHTML = users.filter((item) => {
const itemNameUpper = item.name.toUpperCase();
return !nameFilter || itemNameUpper.includes(nameFilterUpper)
}).map(wrapItemNameInSpan).join(``);
}
// имитация users.json
userJsonURL = 'data:,' + JSON.stringify([
{name: 'filtered'},
{name: 'Vasya-name'},
{name: 'Zlatan-name'}
]);
fetch(userJsonURL)
.then((res) => res.json())
.then((data) => users = data)
.then(render);
</script>