Categories
Learning

Webpack cache issue: start value has mixed support, consider using flex-start instead

Hello,
If you facing issue like below:

//NextJS Compilation Error on Server Start:

(11716:3) autoprefixer: start value has mixed support, consider using flex-start instead
<w> [webpack.cache.PackFileCacheStrategy] Skipped not serializable cache item 'Compilation/modules|F:\WORK\maw\code\node_modules\next\dist\build\webpack\loaders\css-loader\src\index.js??ruleSet[1].rules[2].oneOf[9].use[1]!F:\WORK\maw\code\node_modules\next\dist\build\webpack\loaders\postcss-loader\src\index.js??ruleSet[1].rules[2].oneOf[9].use[2]!F:\WORK\maw\code\node_modules\next\dist\build\webpack\loaders\resolve-url-loader\index.js??ruleSet[1].rules[2].oneOf[9].use[3]!F:\WORK\maw\code\node_modules\next\dist\compiled\sass-loader\cjs.js??ruleSet[1].rules[2].oneOf[9].use[4]!F:\WORK\maw\code\styles\main.scss': No serializer registered for Warning
<w> while serializing webpack/lib/cache/PackFileCacheStrategy.PackContentItems -> webpack/lib/NormalModule -> Array { 1 items } -> webpack/lib/ModuleWarning -> Warning

The reason to this is you are using wrong value, somewhere in your scss or css file, in my case i have set align-items to ‘start‘ which is incorrect so compilation through’s error when running nextjs server. 

align-items start value issue

Fix, is simple correct it with the right value, so I have updated with ‘flex-start’ fixed the compilation issue and server is up and running. 

Hope this quick help would save your time!

Happy Learning.

Categories
Learning Learning Tech

Laravel getting error: Target class [App\Http\Controllers\GurbaniReadingController::class] does not exist. But file already exists!!

Hello Guys,

Facing this issue and struggling to find the cause?, okay then lets direct jump in to the fix I found or more precisely mistake I found!

In picture you might seeing controller name is different than I have mentioned below; I am changed it to Book, so don’t get confuse.

In my case I was wrapped the loading on controller in web.php route with single quotes!

Line of code causing this error:

Route::get('/book-readings/upload-photos', ['App\Http\Controllers\BookReadingController::class', 'uploadPhotos']);

Very carefully watch in above code code was wrapped in quotes: ‘App\Http\Controllers\BookReadingController::class’,
Controller should be loaded without single quotes;

And second important reason is it, this line should shall fall before the resource route if you have similar to this controller, in my case it was :

Route::resource('/book-readings', App\Http\Controllers\BookReadingController::class); 
// this line was defined before the above route I wanted to work! (I am not sure why this line causing to stop showing the page :/)

Finally I make these changes so everything started working smoothly & all routes loading fine and up!.

// Upload Audio Files:
Route::get('/book-readings/upload-photos', [App\Http\Controllers\BookReadingController::class, 'showPhotos'])->name('book-readings.upload-photos');
Route::post('/book-readings/upload-photos', [App\Http\Controllers\BookReadingController::class, 'uploadPhotos']);
Route::delete('/book-readings/upload-photos/{id}', [App\Http\Controllers\BookReadingController::class, 'destroyPhoto']);

Route::resource('/book-readings', App\Http\Controllers\BookReadingController::class);

Hope this will give you a hint to point the issue you might come up like this mostly when we are new and learning and developing new things!

Happy Learnings

Categories
Blog Learning

Curios Question: Wanted to know how much rate would cost me running 10W Laser Machine for 14 mins?

Hello

Welcome here, If you also wondering how much it would cost us for running certain electrical appliance at home for our small work or business and you wondering how to make those calculations to find the rate for that mins or hours of machine running assuming just its running in your home nothing else.

If you were looking for similar answer, lets dive how I have tried to find it out myself with help of latest tech programs online!

Lets Dig In!

Here how I frame my question using the data from my latest Electricity Bill (In India, I am using Tata Power the great source of electricity provider to the nation!)

Based on following data 101-300 Units Energy Charge: 5.65 rupee /kwh, RA charges 0.00 rupee /kwh, CSS charges: 0.35 rupee /kwh, Wheeling Charges : 2.21 rupee /kwh, Fixed Demand Charges: 125.00 rupees, ED 16.00%, Tose: 0.2604 rupee /kwh
If I am running a single machine of 10W laser for 14 mins how much my electricity bill would be?

Question I formed to put in the mouth of AI tool 😛

Here is how AI calculated from the above that and calculate out the result for me:

To calculate the electricity bill, we need to convert the power consumption of the machine from Watts to kilowatts and then multiply it by the energy rate per unit.


10 W = 10/1000 kW = 0.01 kW

The time period is 14 minutes, which we need to convert to hours:

14 minutes = 14/60 hours = 0.2333 hours

The total energy consumption can be calculated as:

Energy consumed = Power x Time = 0.01 kW x 0.2333 hours = 0.002333 kWh

Now, we can calculate the energy charges, demand charges, and other charges as follows:

Energy Charges = Energy consumed x Energy rate per unit
= 0.002333 kWh x 5.65 Rs/kWh = 0.0132 Rs

Fixed Demand Charges = Fixed Demand Charges per billing cycle
= 125.00 Rs (for a single machine)

Wheeling Charges = Energy consumed x Wheeling charges per unit
= 0.002333 kWh x 2.21 Rs/kWh = 0.0051 Rs

CSS Charges = Energy consumed x CSS charges per unit
= 0.002333 kWh x 0.35 Rs/kWh = 0.0008 Rs

ED Charges = Energy charges + Wheeling charges + CSS charges
= 0.0132 Rs + 0.0051 Rs + 0.0008 Rs = 0.0191 Rs

Taxes and Other Surcharges = Energy charges + Wheeling charges + CSS charges + ED charges x Tose rate
= 0.0191 Rs x 0.2604 = 0.00498 Rs

Total Electricity Bill = Energy Charges + Fixed Demand Charges + Wheeling Charges + CSS Charges + ED Charges + Taxes and Other Surcharges
= 0.0132 Rs + 125.00 Rs + 0.0051 Rs + 0.0008 Rs + 0.0191 Rs + 0.00498 Rs
= 125.043 Rs (rounded off to two decimal places)

Therefore, if you run a single 10W laser machine for 14 minutes, your electricity bill would be approximately 125.043 Rs.

Then I said Wow so nice and quick, isn’t it?

But then thought & put my attention on the Fixed Demand Charges which 125/-, would it be a for day? then I thought No its for a month, so how it would calculate for a day? it simply as you would also know this to divide in my number of days in a month, right?

So to see if AI response the result back with more in detail with assuming and consuming similar data passed before, here is reframed question I have put (in the mouth of AI tool)

can you do this divide fixed charges by month of days and return everything again?

question for AI tool

This is what it finally answered back;

Sure, to calculate the fixed demand charges per day, we can divide the monthly fixed demand charges by the number of days in the month.

Assuming a 30-day billing cycle, the fixed demand charges per day would be:

Fixed Demand Charges per day = Fixed Demand Charges per month / Number of days in the month
= 125.00 Rs / 30 days
= 4.1667 Rs per day

Now, we can calculate the updated energy charges, wheeling charges, CSS charges, ED charges, and taxes and other surcharges per unit of energy consumed, which would be:

Energy Charges = 5.65 Rs /kWh
Wheeling Charges = 2.21 Rs /kWh
CSS Charges = 0.35 Rs /kWh
ED Charges = Energy charges + Wheeling charges + CSS charges
= 5.65 Rs/kWh + 2.21 Rs/kWh + 0.35 Rs/kWh
= 8.21 Rs/kWh

Taxes and Other Surcharges = ED charges x Tose rate
= 8.21 Rs/kWh x 0.2604
= 2.1384 Rs/kWh

To calculate the total electricity bill for running a 10W laser machine for 14 minutes per day, we can use the same method as before, but now we have updated values for the fixed demand charges, ED charges, and taxes and other surcharges.

Energy consumed per day = Energy consumed per hour x Hours per day
= 0.01 kW x 0.2333 hours/day
= 0.002333 kWh/day

Energy Charges per day = Energy consumed per day x Energy rate per unit
= 0.002333 kWh/day x 5.65 Rs/kWh
= 0.0132 Rs/day

Fixed Demand Charges per day = Fixed Demand Charges per month / Number of days in the month
= 125.00 Rs / 30 days
= 4.1667 Rs/day

Wheeling Charges per day = Energy consumed per day x Wheeling charges per unit
= 0.002333 kWh/day x 2.21 Rs/kWh
= 0.0051 Rs/day

CSS Charges per day = Energy consumed per day x CSS charges per unit
= 0.002333 kWh/day x 0.35 Rs/kWh
= 0.0008 Rs/day

ED Charges per day = Energy charges per day + Wheeling charges per day + CSS charges per day
= 0.0132 Rs/day + 0.0051 Rs/day + 0.0008 Rs/day
= 0.0191 Rs/day

Taxes and Other Surcharges per day = ED charges per day x Tose rate
= 0.0191 Rs/day x 0.2604
= 0.00498 Rs/day

Total Electricity Bill per day = Energy Charges per day + Fixed Demand Charges per day + Wheeling Charges per day + CSS Charges per day + ED Charges per day + Taxes and Other Surcharges per day
= 0.0132 Rs/day + 4.1667 Rs/day + 0.0051 Rs/day + 0.0008 Rs/day + 0.0191 Rs/day + 0.00498 Rs/day
= 4.2098 Rs/day

Therefore, if you run a single 10W laser machine for 14 minutes per day, your electricity bill would be approximately 4.2098 Rs/day

Hurray! Isn’t it fun?

Hope you enjoyed this puzzle solving question answer game when really you want to know the difficult question you have all time in our head, but latest techs help’s out in secs with such quick answers!

Keep exploring keep learning!

Source : Open AI Chat GPT

P.S. Not sure what it calculated it reflect exact what we are looking, I assuming it calculated to be accurate!

Categories
Javascript Learning

How to fix Uncaught TypeError: Cannot assign to read only property ‘0’ of object occurring in JavaScript?

Hello,

This type error mostly get in scenario when you try to sort the readyonly data array.

For me this was occoured when I tried to sort the direct result from my GraphQL query response data like below:

const sortedData = data.bhangarwalas.sort((a, b) => a?.firstname > b?.firstname ? 1 : -1);

In above, data.bhangarwalas is graphql query response results which is readonly in nature as response.

To fix this issue the solution is quick fix for which I have too google to know the result!

Error Screenshot Uncaught TypeError: Cannot assign to read only property ‘0’ of object ‘[object Array]’

Here is the quick solution:

const sortedData = [...data.bhangarwalas];
      sortedData.sort((a, b) => a?.firstname > b?.firstname ? 1 : -1);

In code above, We need to clone or you in other words, copying the “data.bhangarwalas” into new array variable and then over that variable, we need to perform sorting operation, which results us right response.

Hope this help you to solve the quick error or to know what scenario this type of error is generated.

Thanks for reading.

Happy learning!

Categories
Learning

What to do when you don’t quickly find UTS scan code at a Mumbai Railway Station you are at?

Hello,

You are facing too? Not to worry.

The challenge of finding UTS Mumbai Station Scan QR scan code if you are standing at other the end of the station where UTS scan code is not available quickly.

Just quickly jump over to this site : MUMBAI RAILWAY STATION UTS SCAN CODE find the station and scan the code right away and Book your ticket from UTS App.

UTS Scan code Mumbai [Western|Centeral|Eastern]

Incase if you not find the UTS Scan code you can quickly drop a note to them at  utsqrscan@doableyo.com to add your favorite station QR code on the list!

Hope this helps.

Thanks for visiting. Please share with your friends and family if you love their work!

Categories
Javascript Learning Tech

What to do when you get nextjs error (Module not found: Error: Can’t resolve ‘private-next-pages/’ in ‘/vercel/path0’) on vercel/nextjs deployment?

Hello,

If you too facing this error : Module not found: Error: Can’t resolve ‘private-next-pages/’ in ‘/vercel/path0’

while deploying your NextJs project over Vercel platform, please follow what solution and mistake I was doing.

Error Screenshot of error occurring from the NextJs Project deployment on vercel platform.

As, I tried to debug this error by right away check the the next in the log highlighted (in screenshot above) recommending to following alias rule to be set if you have touched you next.config.js file with any webpack settings.

In my case I did have to touched the next.config.js file and so I have add the same lines of code recommend in the follow link of Next.js doc

https://nextjs.org/docs/messages/invalid-resolve-alias

But for me still I didn’t found the right solution, because was in the naming of folder under nextjs project.

Basically, I was loading the static content into the dynamic route in Nextjs (Like example reference here).

What I have missed was the name of the folder under pages directory I have created named as “learn” it should be similar to name “posts” as created one at root level of the project to hold the “.md” or “.html” file content to pass down to dynamic route page which will be under /pages/posts/[id].js

Sharing here screenshot of the directory where the naming was a mistake

Here highlighted “learn” folder should be same as “posts” below

After renaming the folder name “learn” to “posts” the error went off and found my deployment working successfully.

Hope this small mistake tip help you to solve this problem.

If you have found any mistake in the post. Please don’t hesitate to hit me on my email jat@doableyo.com to rectify.

Enjoyed reading this? How about sharing with your friends or in groups, this would help!

Thanks, Happy Learning!

Categories
Learning

ReactJS Component Skeleton for Register/Create Account

Hello,

Welcome, here is how you can create a get to started ReactJS Register/Create Account component from scratch with very basic fields for your website or application.

import React from "react";

function CreateAccount() {

    const [formValues, setFormValues] = useState({
        role: '',
        name: '',
        mobile: '',
        email: '',
        password: '',
        confirmPassword: ''
    });

    const handleInputChange = e => {
        const { name, value } = e.target;
        setFormValues({ ...formValues, [name]: value });
    };

    const handleSubmit = e => {
        e.preventDefault();
        // You can perform your form submission logic here
        console.log(formValues);
    };

    return (<>
        <div className="card">
            <div className="card-body">
                <form method="POST" action="https://doableyo.com/atamsamagam/admin/register">
                    {/* <input type="hidden" name="_token" defaultValue="zdDR1NfxywhlhmpIqNTZ7uNUvl1luoUe7X0N6GOh" /> 
                        for CSRF!
                    */}
                    <div className="form-group row">
                        <label htmlFor="role" className="col-md-4 col-form-label text-md-right">Role</label>
                        <div className="col-md-6">
                            <select id="role" name="role" className="form-control  text-capitalize" required autoComplete="role" autofocus>
                                {/* need a fix of admin */}
                                <option value="user">user</option>
                                <option value="admin">admin</option>
                            </select>
                        </div>
                    </div>
                    <div className="form-group row">
                        <label htmlFor="name" className="col-md-4 col-form-label text-md-right">Name</label>
                        <div className="col-md-6">
                            <input id="name" type="text" className="form-control " name="name" defaultValue required autoComplete="name" autofocus />
                        </div>
                    </div>
                    <div className="form-group row">
                        <label htmlFor="mobile" className="col-md-4 col-form-label text-md-right">Mobile</label>
                        <div className="col-md-6">
                            <input id="mobile" type="number" required minLength={10} maxLength={10} className="form-control " name="mobile" defaultValue autoComplete="mobile" />
                            <small>Enter without country code or + character</small>
                        </div>
                    </div>
                    <div className="form-group row">
                        <label htmlFor="email" className="col-md-4 col-form-label text-md-right">E-Mail Address</label>
                        <div className="col-md-6">
                            <input id="email" type="email" className="form-control " name="email" defaultValue required autoComplete="email" />
                        </div>
                    </div>
                    <div className="form-group row">
                        <label htmlFor="password" className="col-md-4 col-form-label text-md-right">Password</label>
                        <div className="col-md-6">
                            <input id="password" type="password" className="form-control " name="password" required autoComplete="new-password" />
                        </div>
                    </div>
                    <div className="form-group row">
                        <label htmlFor="password-confirm" className="col-md-4 col-form-label text-md-right">Confirm Password</label>
                        <div className="col-md-6">
                            <input id="password-confirm" type="password" className="form-control" name="password_confirmation" required autoComplete="new-password" />
                        </div>
                    </div>
                    <div className="form-group row mb-0">
                        <div className="col-md-6 offset-md-4">
                            <button type="submit" className="btn btn-primary">
                                Create
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </>)
}

export default CreateAccount;

Source: Self Learned & AI ChatGPT Channel

Happy learning!

Categories
Tech

Show 3 cards next to each other and rest follow below similar, how should I write code in css using flex?

Hello,

To display 3 cards next to each other using CSS flex, you can use the flex-wrap property with a value of wrap, combined with the flex property to set the size of each card. Here is an example:

<div class="card-container">
  <div class="card">Card 1</div>
  <div class="card">Card 2</div>
  <div class="card">Card 3</div>
  <div class="card">Card 4</div>
  <div class="card">Card 5</div>
  <div class="card">Card 6</div>
  <div class="card">Card 7</div>
  <div class="card">Card 8</div>
  <div class="card">Card 9</div>
</div>

CSS:

.card-container {
  display: flex;
  flex-wrap: wrap;
}

.card {
  flex-basis: calc(33.33% - 10px); /* Set the width of each card to one-third of the container minus some margin */
  margin-right: 10px; /* Add some margin between the cards */
  margin-bottom: 10px; /* Add some margin below the cards */
  background-color: #f5f5f5;
  padding: 10px;
  box-sizing: border-box;
}

In this example, the card-container element is set to display: flex, which makes its child elements align horizontally in a row. The flex-wrap: wrap property allows the cards to wrap onto the next row when there isn’t enough space for them all to fit on one row. The flex-basis property is used to set the width of each card to one-third of the container minus some margin, and the margin-right and margin-bottom properties add some spacing between the cards. The box-sizing: border-box property ensures that the padding of each card is included in its width calculation.

Source: AI Interaction Channel

Happy Learning!

Categories
Javascript Tech

What is Event Loop & Micro and Macro Tasks in JavaScript?

Hello,

The basic concept behind the event loop working in Javascript engine!

Event Loop is a mechanism in JavaScript that handles asynchronous tasks in a non-blocking way. When JavaScript code is executed, it is run inside an event loop, which continuously checks if there are any tasks to be executed in the queue. The event loop is responsible for running the tasks in the queue, and it does this in a specific order.

The Event Loop in JavaScript has two main components: the Call Stack and the Callback Queue. The Call Stack is responsible for keeping track of the execution of the synchronous code. When a function is called, it is added to the top of the call stack, and when the function returns, it is removed from the top of the call stack.

The Callback Queue, on the other hand, is responsible for keeping track of the asynchronous tasks. When an asynchronous task is completed, it is added to the Callback Queue. The event loop continuously checks the Callback Queue to see if there are any tasks that can be executed. If there is a task, it is moved to the Call Stack, where it is executed.

Microtasks and Macrotasks are two types of tasks in JavaScript that are executed by the event loop.

Microtasks are tasks that are executed immediately after the current task has completed. Microtasks are executed before the next rendering of the web page, which means that they have a higher priority than Macrotasks. Some examples of Microtasks include Promises, MutationObserver, and process.nextTick in Node.js.

Macrotasks, on the other hand, are tasks that are executed after all the Microtasks have been executed. Macrotasks include tasks such as setTimeout, setInterval, and I/O operations in Node.js.

In summary, the Event Loop in JavaScript is responsible for handling asynchronous tasks in a non-blocking way. The Event Loop has two main components, the Call Stack and the Callback Queue. Microtasks and Macrotasks are two types of tasks that are executed by the event loop, and they have different priorities. Microtasks are executed before Macrotasks and are used for tasks that need to be executed immediately after the current task has completed, while Macrotasks are used for tasks that can be executed at a later time.

Source: AI Interaction Channels

Happy Learning!

Categories
Javascript Tech

How to identify closed 5km range co ordinates from given co ordinates

Hello,

This nice question and other below I have learned recently! Let see how its answered.

To identify the closed 5km range coordinates from a given set of coordinates, you need to first calculate the difference in latitude and longitude between the given coordinates and find the minimum and maximum values.

Here’s the basic formula:

Latitude range:

  • min latitude = given latitude – (5 / 111.2)
  • max latitude = given latitude + (5 / 111.2)

Longitude range:

  • min longitude = given longitude – (5 / (111.2 * cos(given latitude)))
  • max longitude = given longitude + (5 / (111.2 * cos(given latitude)))

Note: In the above formula, (5 / 111.2) is used to convert 5km to degrees. The value of 111.2 is the approximate number of km per degree of latitude. The value of (111.2 * cos(given latitude)) is used to convert 5km to degrees of longitude.

Once you have calculated the minimum and maximum values of latitude and longitude, you can create a bounding box by combining them. The coordinates within this bounding box would be considered as closed within a 5km range of the given coordinates.

Can you tell me more on last results?

Sure! The last results I mentioned are the coordinates of a bounding box that defines a closed area within a 5km range of a given set of coordinates.

A bounding box is a rectangular area that encloses a set of points or coordinates. In this case, the bounding box encloses the coordinates that are within a 5km range of the given coordinates. The minimum and maximum latitude and longitude values that were calculated earlier define the boundaries of this bounding box.

By combining the minimum and maximum latitude and longitude values, you get a rectangular area that encloses all the coordinates that are within a 5km range of the given coordinates. Any coordinate that lies within this rectangular area can be considered to be within a 5km range of the given coordinates.

This information can be useful in various applications, such as mapping, geolocation-based services, or location-based searches. For example, if you want to search for all the restaurants within a 5km range of a given location, you can use the bounding box coordinates to filter out the restaurants that are outside the 5km range.

Can you tell me more with example for bounding box calculations?

Sure, here’s an example of how you can calculate the bounding box coordinates for a given set of coordinates within a 5km range.

Let’s assume that the given coordinates are:

Latitude: 37.7749 Longitude: -122.4194

To calculate the bounding box coordinates:

  1. Calculate the minimum and maximum latitude:
  • min latitude = 37.7749 – (5 / 111.2) = 37.7692
  • max latitude = 37.7749 + (5 / 111.2) = 37.7807
  1. Calculate the minimum and maximum longitude:
  • min longitude = -122.4194 – (5 / (111.2 * cos(37.7749))) = -122.4257
  • max longitude = -122.4194 + (5 / (111.2 * cos(37.7749))) = -122.4131

So, the bounding box coordinates would be:

min latitude: 37.7692 min longitude: -122.4257 max latitude: 37.7807 max longitude: -122.4131

This means that any coordinate that lies within the rectangular area defined by these bounding box coordinates would be considered to be within a 5km range of the given coordinates (37.7749, -122.4194).

Well hope you understand from the given formulation and examples how can create a boundingbox for the range we need to search in for against our given co-ordinates, lets deep in further how we can implement and take this up with our Javascript Skills!

Nice, how I we can use this in Javascript?

Here’s an example of how you can calculate the bounding box coordinates for a given set of coordinates within a 5km range using JavaScript:

function getBoundingBox(lat, lng, distance) {
  const RADIUS_OF_EARTH_KM = 6371;
  const latRadian = lat * (Math.PI / 180);
  const degLatKm = RADIUS_OF_EARTH_KM * Math.cos(latRadian);
  const degLonKm = RADIUS_OF_EARTH_KM;
  const latDegree = distance / degLatKm;
  const lngDegree = distance / degLonKm;

  return {
    minLat: lat - latDegree,
    minLng: lng - lngDegree,
    maxLat: lat + latDegree,
    maxLng: lng + lngDegree
  };
}

const coordinates = { lat: 37.7749, lng: -122.4194 };
const boundingBox = getBoundingBox(coordinates.lat, coordinates.lng, 5);

console.log(boundingBox);

In this example, the getBoundingBox function takes the latitude, longitude, and distance as input parameters. The distance is the radius of the bounding box and is specified in kilometers. The function first converts the latitude and longitude to radians and calculates the number of kilometers per degree of latitude and longitude. The minimum and maximum latitude and longitude values are then calculated using these values and the given distance. Finally, the bounding box coordinates are returned as an object.

Nice, How to I use the bounding box with real test case example?

Here’s an example of how you could use the bounding box coordinates with a real-world test case. Let’s say you have a list of restaurants and their coordinates, and you want to search for all the restaurants within a 5km range of a given location.

const restaurants = [
  { name: "Restaurant A", lat: 37.7820, lng: -122.4464 },
  { name: "Restaurant B", lat: 37.7696, lng: -122.4138 },
  { name: "Restaurant C", lat: 37.7816, lng: -122.4140 },
  { name: "Restaurant D", lat: 37.7711, lng: -122.4336 },
  { name: "Restaurant E", lat: 37.7634, lng: -122.4359 },
];

const searchLocation = { lat: 37.7749, lng: -122.4194 };
const searchRadius = 5;
const boundingBox = getBoundingBox(searchLocation.lat, searchLocation.lng, searchRadius);

const filteredRestaurants = restaurants.filter(restaurant => {
  return (
    restaurant.lat >= boundingBox.minLat &&
    restaurant.lat <= boundingBox.maxLat &&
    restaurant.lng >= boundingBox.minLng &&
    restaurant.lng <= boundingBox.maxLng
  );
});

console.log(filteredRestaurants);

In this example, the restaurants array contains the list of restaurants and their coordinates. The searchLocation object contains the location for which you want to search the restaurants. The searchRadius specifies the radius of the search in kilometers.

The boundingBox is calculated using the getBoundingBox function, as shown in the previous example. The filteredRestaurants array is then created by filtering the restaurants array based on whether their coordinates fall within the bounding box or not. Finally, the filtered restaurants are logged to the console.

Hope this give us nice insight for the questions we have and need to develop as we develop advance things.

Source: Some AI Interaction Channels

Happy Learning!