In my scripts.js, I've implemented async functions to execute asynchronous operations. For instance:
async function getPostcodeCoordinates(postcode) {...}
I've utilized event listeners as callbacks in my code:
postcodeInput.addEventListener("keydown", function (event) {...});
In my getPostcodeCoordinates function, I've employed the fetch method, which inherently returns a promise:
const response = await fetch(url);
I've made several HTTP requests using the fetch method in my code, such as:
const response = await fetch(url);
Within the code I provided, I'm primarily making GET requests with fetch. An example is:
const boundaryResponse = await fetch(boundaryUrl);
I utilized the map method in the fetchAndDrawBoundaryCoordinates function to convert boundaryData into a format suitable for Leaflet:
const leafletCoords = boundaryData.map((coord) => [...]);
Though I've employed methods like find in my code, I didn't directly incorporate the filter method in the examples I provided.
I accessed several DOM nodes using methods like getElementById:
const mapElement = document.getElementById("map");
While I didn't directly add or remove any DOM nodes, I modified the content of certain nodes in the code:
const neighbourhoodLabel = document.getElementById("neighbourhood");
neighbourhoodLabel.textContent = `Crime in: ` + neighbourhoodName;
In my code, I toggled the spin class on the crosshair element to achieve specific visual effects:
crosshair.classList.add("spin");
crosshair.classList.remove("spin");
I've maintained a consistent layout and spacing throughout my code, ensuring it remains clean and readable.
I've maintained a consistent layout and spacing throughout my code, ensuring it remains clean and readable.
Though direct debugging isn't showcased in the code I provided, I've made use of console.log statements throughout my JavaScript as a debugging aid:
console.log("Success getting crimes");
To aid my debugging process, I frequently incorporated console.log in various places. Here's an example:
console.log("Postcode coordinates:", latitude, longitude);