a1/fetch.js

22 lines
649 B
JavaScript
Raw Normal View History

2024-05-20 05:14:55 +00:00
const url = "http://localhost/p20/get.php"
2024-05-15 10:24:25 +00:00
2024-05-20 05:14:55 +00:00
fetch(url)
2024-05-15 10:24:25 +00:00
.then(response => response.json())
2024-05-20 05:14:55 +00:00
.then(data => {
2024-05-15 10:24:25 +00:00
console.log(data)
2024-05-20 08:04:52 +00:00
})
function sortujSufiksy() {
const slowo = document.getElementById('slowo').value;
const sufiksy = [];
for (let i = 0; i < slowo.length; i++) {
sufiksy.push(slowo.slice(i));
}
document.getElementById('nieposortowane').textContent = formatSufiksy(sufiksy);
sufiksy.sort();
document.getElementById('posortowane').textContent = formatSufiksy(sufiksy);
}
function formatSufiksy(sufiksy) {
return sufiksy.map((sufiks, index) => `${index + 1} ${sufiks}`).join('\n');
}