a1/fetch.js

21 lines
656 B
JavaScript
Raw Normal View History

2024-05-20 05:49:37 +00:00
const url = "http://localhost/P20.05/get.php"
2024-05-15 10:24:25 +00:00
2024-05-20 05:49:37 +00:00
fetch(url)
2024-05-15 10:24:25 +00:00
.then(response => response.json())
.then( data => {
console.log(data)
2024-05-20 05:49:37 +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');
}