Skip to content

Tag: javascript

I am trying to solve a challenge from jshero.net

I am trying to solve a challenge from jshero.net Write a function add that adds an element to the end of an array. However, the element should only be added if it is not already in the array. Example: add([1, 2], 3) should return [1, 2, 3] and add([1, 2], 2) should return [1, 2]. why didn’t work this co…

How to redirect to another page using on keypress in nextjs?

I need to redirect users using onkeypress in nextjs. I have a search input where users can type and then press enter key to go to the other page. What I’ve tried: i would appreciate your help. Answer You can use the useRouter hook from next – https://nextjs.org/docs/api-reference/next/router Try c…

code event[] calendar in laravel 8 not working

I created a calendar with laravel 8 and PHP 8,it is running ok in php 7 but I have to upgrade to php 8 because of the demands of the times I have successfully saved data in the database but the data in mysql does not appear in the calendar, even though I have used event[], I have checked that

Chart.js: Why are there two y axes in my line graph?

I’m using chart.js to build a line graph. I can’t figure out why there are two y-axes on my graph. I also tried changing the color of the tick labels to white but it isn’t working either. Thanks for your help! Here’s the preview of my code: https://codepen.io/suminohh/pen/vYROrEx Answe…

Unable to load CSS file within nodeJS app

I have an app that I followed from a tutorial for the backend in nodeJS and Express. My connection to MongoDB via Mongoose is working. However, I’ve been trying to add a front-end- at the moment- just a simple html/ejs/css form. My endpoints are loading in localhost but only the html/ejs is rendering. M…

For Loop while referring to an array with Length

I’m very new to javascript and have just recently learned about For loops. I have a variable that consists of an array containing a bunch names, and I would like to add last names to each of them. I wrote the code as shown below and have a few questions. Result : Questions: About the second statement fo…