about nextLine() in java

I have that code I work on it and every think is fine until I wrote a
String c = s.nextLine();
and it’s not work he is sikp the enter from the user and go to next one and I don’t know where is the problem maybe logic error or some think like this but until I delete a Line it’s became next(); and it’s work but if i want to be nextLine() what can i do ?and I would like to know why isn’t work with me and work with me with another code?

so hear is the class redio

package radiotester;

public class Radio {
    private double frequency;
   private String channel;
   private int followers;

    public Radio() {
    frequency=0.0;
    channel="";
   followers=0;
    }

    public Radio(double frequency, String channel, int followers) {
        this.frequency = frequency;
        this.channel = channel;
        this.followers = followers;
    }
    
    public void printAll (){
    
    System.out.println("the frequency ="+frequency);
    System.out.println("the channel = "+channel);
    System.out.println("the followers = "+followers);
    }

    public void setFrequency(double f) {
        f = frequency;
    }

    public double getFrequency() {
        return frequency;
    }
   
}

and here is the test of class raido
here is the problem

package radiotester;
import java.util.Scanner;
public class RadioTester {

    public static void main(String[] args) {
       Scanner s = new Scanner (System.in);
  Radio Radio1 = new Radio ();
  Radio1.printAll();
  
  
  System.out.println("plase give the raido requency");
  double r = s.nextDouble();
    
  
System.out.println("plase give the raido channle");
String c = s.next();
System.out.println("plase give the raido follwers");
int f = s.nextInt();
    Radio Radio2 = new Radio (r,c,f);
    
    System.out.println("old character of raido2");
    Radio2.printAll();
    Radio2.setFrequency(100.5);
        System.out.println("new character of raido2");
            Radio2.printAll();

    
}}

DiscordJs registered command dont show up

I want to build a discord bot with slash commands. I use the following script to register the commands:

index.js

require("dotenv").config();
const fs = require("node:fs");
const { REST } = require("@discordjs/rest");
const { Routes } = require("discord-api-types/v9");
const { Client, Intents, Collection, Interaction, ClientUser } = require('discord.js');

// Create a new client instance
const client = new Client({
    intents: [
        Intents.FLAGS.GUILDS,
        Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
        Intents.FLAGS.GUILD_MESSAGES
    ]
});

const commandFiles = fs.readdirSync("./commands").filter(file => file.endsWith(".js"));

const commands = [];
const GUILDID = process.env.GUILDID;

client.commands = new Collection();

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    commands.push(command.data.toJSON());
    client.commands.set(command.data.name, command);
};

const rest = new REST ({version: "9"}).setToken(process.env.TOKEN);

client.once("ready", () => {    
    console.log("Ready");

    const CLIENT_ID = client.user.id;

    (async () => {
        try {
            if(process.env.ENV === "production"){
                await rest.put(Routes.applicationCommands(CLIENT_ID),{
                    body: commands
                });
                console.log("Successfully registered commands globally");
            } else {
                await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILDID), {
                    body: commands
                });
                console.log("Successfully registered commands locally");
            }
        } catch (err) {
            if (err) console.error(err);
        }
    })();
});


client.login(process.env.TOKEN);

I have one command so far called “ping.js” which is in the commands folder, which is in my project folder.

ping.js

const { SlashCommandBuilder } = require("@discordjs/builders");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("ping")
        .setDescription("pong"),
    async execute(interaction) {
        interaction.reply({
            content: "Pong",
            ephemeral: true
        })
    }
}

I also have an .env file in the project folder.

ENV=test
TOKEN=****
GUILDID=****

The script runs without errors and I get “Successfully registered commands locally” as a feedback, but the command dont show up in Discord. I have tried to register the bot again, restart my PC and the terminal and I have checked the code multiple times.
Whats make this a bit frustrating is that it first works and let me run the ping command, but after adding another command, the new one dont showed up. And now I have deleted the secound command again but cant get back.

Thank you all very much for you help in advance

How to rerender 2 unrelated component in react without rerendering the whole page?

Suppose I have 2 components A and B which are not linked (by props), but which are linked by the database. component A has a button that changes the data in the database. And I want component B (only with A) to render when the database changes. The problem is, that when the component A mutate the database, tha have to refresh the page to see the change in component B
It’s may be a weird question but, I’m still a beginner in react

Vec3 function to create color

Can someone please help me understand what this valueToColor does?(https://github.com/Rylern/InterpolateHeatmapLayer)

vec3 valueToColor(float value) {
  return vec3(max((value-0.5)*2.0, 0.0), 1.0 - 2.0*abs(value - 0.5), max((0.5-value)*2.0, 0.0));
}

I am trying create this color scheme but I am not used to using vec3. The goal My goal is to set the color something like this.
How can this be done in javascript?
Documentation for the valueToColor.

How to center form correctly in react using tailwind CSS?

Hi I am a beginner to tailwind CSS and I was creating a form for my personal project. I noticed that upon adding about 15-20 <input/> tags for testing. It seems that some of my <input /> tags go out of view in my pc. Upon adding even overflow-y-scroll it scrolls only a bit but most of my content gets hidden or doesn’t show. I have to zoom out to view everything. I tried adding h-screen in different divs but nothing seems to work. Here is my code.


<div className="bg-[#070817] overflow-y-scroll px-10 h-screen flex flex-col items-center justify-center ">
      <p className="text-[#FF9776] text-4xl font-bold pb-5">Add a Container</p>

      <form className="">
        <input
          aria-label="Enter your email address"
          type="text"
          placeholder="Username"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="First Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
       <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
       <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
       <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
       <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />
        v
 <input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        /><input
          aria-label="Details"
          type="text"
          placeholder="Last Name"
          className="text-white font-medium text-sm text-gray-base w-full mr-3 py-5 px-4 h-2 rounded-2xl mb-2 placeholder:font-medium bg-slate-900 outline-none"
        />


        <button
          type="submit"
          className="bg-[#FF9776] w-full rounded-2xl p-2 mt-4"
        >
          Add User
        </button>
      </form>
    </div>

Here are the Images
enter image description here

Notice that I cannot scroll

Proper way to add an event after setting html

Let’s say I have an element that I want to write the html of, for example:

const tr = ...;
tr.innerHTML = `<td>...</td>`;

Is there a way to write the html so that I have an event listener already on it, or do I need to use a new selector and add the event listener to it, such as with:

tr.querySelector('td').addEventListeneer('click', myFunction);

Or how is this normally done?

How do I define custom renderers for default Markdown elements using markdoc.io?

The React documentation on markdoc.io explains how to use the custom Callout and it works really well 🙂

If I transform it like this:

  Markdoc.transform(node, {
    tags: {
      callout: {
        render: "Callout",
      },
    },
  });

and render it like this:

 Markdoc.renderers.react(props.content, React, {
    components: {
      Callout: Callout,
    },
  });

If write

{% callout %}
Attention, over here!
{% /callout %}

It works.

The problem is that, I’m trying to use the exact same concept but write

# This is a title

I cannot make it to render my custom React component. It just always renders an h1 HTML tag.

Any idea?

Bootstrap card content overflowing past background height

I am currently running into an issue with my HTML/CSS (Bootstrap 5.0) code. I am trying to implement a Pinterest style Masonry card gallery using the Bootstrap 5.0 grid system and the Masonry library. The issue I run into is that the content overflows past the background container height. The cards also seem to stack over each other until you resize the window.

Is there a better way to implement a Masonry layout with Bootstrap 5.0 or any issues you can see with my code that would cause this overflow height/stacking issue? Let me know if I can provide any more information or code:

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <link rel="stylesheet" href="bootstrap.css" type="text/css" />
        <link rel="stylesheet" href="style.css" type="text/css" />
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
        <title>Grayson Felt</title>
    </head>
        <div class="background-image">
            <nav class="navbar navbar-expand-lg navbar-light bg-light">
                <div class="container-fluid px-4">
                    <a class="navbar-brand" href="index.html">
                    <h2 style="color: var(--light-blue)">
                    <i class="bi bi-postage-heart"></i>
                    </h2>
                    </a>
                    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav">
                        <li class="nav-item">
                        <a class="nav-link" href="index.html">Home</a>
                        </li>
                        <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="#">Gallery</a>
                        </li>
                        <li class="nav-item">
                        <a class="nav-link" href="professional.html">Professional</a>
                        </li>
                    </ul>
                    </div>
                </div>
                </nav>
            <div class="whole px-5 p-3 my-3">
                <div class ="px-5 p-3 my-3 justify-content-center container-fluid bg-white-trans">

                    <h1 class="text-center display-3">Gallery</h1>

                    <div class="container py-5">

                        <div class="row row-cols-1 row-cols-md-3 g-4" data-masonry='{"percentPosition": true }'>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/200/300" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/300/200" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/200/300" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/300/200" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/200/300" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                            <div class="col">
                                <div class="card">
                                    <img src="https://picsum.photos/id/237/200/300" class="card-img-top" alt="...">
                                    <div class="card-body">
                                    <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                                    </div>
                                </div>
                            </div>

                        </div>                
                    </div>

                </div>
            </div>
        </div>            
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/masonry.pkgd.min.js" integrity="sha384-GNFwBvfVxBkLMJpYMOABq3c+d3KnQxudP/mGPkzpZSTYykLBNsZEnG2D9G/X/+7D" crossorigin="anonymous" async></script>
</html>

Non-Bootstrap CSS Properties


:root{
    --light: #7C766A;
    --dark: #4D473E;
    --gray: #B8B8B8;
    --white: #D9D9D9;
    --black: #010400;
    --purple: #594AF6;
    --blue: #40B2B2;
    --green: #AFB116;
    --yellow: #D0A000;
    --red: #A54738;
}

.background-image{
    background-image: url('https://www.teahub.io/photos/full/17-179150_2560x1600-monet-desktop-wallpaper-monet-poppies.jpg');
    position: absolute;
    top: 0px;
    right: 0px;
    bottom: 0px;
    left: 0px;
  }

a:link{     color:var(--blue);  }
a:visited { color:var(--purple);}

header, .post{
    -webkit-box-shadow: 0px 10px 0px 1px var(--dark);  /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
    -moz-box-shadow:    0px 10px 0px 1px var(--dark);  /* Firefox 3.5 - 3.6 */
    box-shadow:         0px 10px 0px 1px var(--dark);  /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
    background-color:var(--white);
    border-radius: 10px;
    padding:40px;
    margin:40px;
}

.post-head p{
    color:var(--dark);
    font-size:15px;
    padding-bottom:30px;
}

.post-head h3{
    font-size:20px;
    color:var(--dark);
}

.post img{
    height:200px;
    width: 200px;
    margin:10px;
}

.sidenav {
    -webkit-box-shadow: 0px 10px 0px 1px var(--dark);  /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
    -moz-box-shadow:    0px 10px 0px 1px var(--dark);  /* Firefox 3.5 - 3.6 */
    box-shadow:         0px 10px 0px 1px var(--dark);  /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
    border-radius: 10px;
    height: 86%;
    width: 20%;
    position: fixed;
    z-index: 1;
    top: 0;
    right: 0;
    background-color: var(--white);
    overflow-x: hidden;
    padding-top: 20px;
    padding-bottom: 20px;
    margin:40px;
  }
  
  .sidenav p{
      margin-left:40px;
  }

  @media screen and (max-width: 1650px) {
      .sidenav{
          display:none !important
      }
      header, .post{
          width:75%
      }
  }

  .highlight{
    text-decoration:underline 2px;
    text-decoration-color:var(--yellow);
}

.rainbow{
    background: url(assets/rainbow.JPG) no-repeat center center fixed;
    background-size: 100% 100%;
    height:5px;
    position:fixed;
    left:0px;
    bottom:0px;
    width:100%;

}

/* this is needed to make the content scrollable on larger screens */
@media (min-width: 576px) {
    .h-sm-100 {
        height: 100%;
    }
}

 @media (max-width: 600px) {
    .whole {
      width:100%;
    }

  }
  @media (min-width:600px) {
    .whole {
      width:90%;
      align-content: center;
      justify-content: center;
      margin: auto;
      
    }
  }

Edit:

Here is an image of the overflow/stacking issue: stack/overflow issue

Showing and Hiding a div with a select in vanilla javascript

I am trying to show input elements in a form with HTML select options. I have 3 options DVD, book and furniture. Each has its product description input field such as weight, height, size (MB) and length. These inputs should be hidden and only show when the select option is changed. I want to use a for loop and not if or else conditionals. I am having trouble getting it to work, with the relevant hidden input to hide and show when the select button is selected.

<section class="add_products">
        <form class="input-form" action="" id="product_form">
            <div class="data-input">
                <label for="sku">SKU#:</label> 
                <input type="text" id="sku" name="sku">
            </div>
            
            <div class="data-input">
                <label for="name">NAME:</label>
                <input type="text" id="name" name="name">
            </div> 
           
            <div class="data-input">
                <label for="price">PRICE ($):</label>
                <input type="number" id="price" name="price">
            </div>
            
            <div class="input-group switcher"  >
                <label for="productType">Type Switcher:</label>
                <select class="list_products" id="productType" name="TypeSwitcher" 
                     onchange="selectChanged()">
                    <option value="1">DVD</option>
                    <option value="2">Book</option>
                    <option value="3">furniture</option>
                </select>
            </div>
          
            <div class="data-input product hidden">
                <label for="size">Size (MB):</label>
                <input type="number" class="hidden" id="size" name="price">
                <p class="describe">Please provide size in (MB)</p>
            </div>
            
            <div class="furniture product hidden">
                <label for="height">Height (CM):</label>
                <input type="number"  id="height" name="price">
            </div> 
            <div class="furniture product hidden">
                <label for="width">Width (CM):</label>
                <input type="number"  id="width" name="price">
            </div>
        
            <div class="furniture product hidden">
                <label for="length">Length (CM):</label>
                <input type="number" id="length" name="price">
                <p class="describe">Please provide measurements in (CM)</p>
            </div>
    
            <div class="data-input product hidden">
                <label for="weight">Weight (KG):</label>
                <input type="number" id="weight" name="price">
                <p class="describe">Please provide weight in KG</p>
            </div>

<script>

var display = {
    1: [],
    2: ["book"],
    3: ["dvd"],
    4: ["Furniture"],
   
  }
  
  function selectChanged() {
    var sel = document.getElementById("productType");
    for (var i = 1; i < 4; i++) {
          document.getElementById("product" + i).classList.add("hidden");
    }
    display[sel.value].forEach(function(i) {
          document.getElementById("product" + i).classList.remove("hidden");
    });
  }
  
</script>

Sorting an array with a compare function – javascript

I came across this sorting of an array and I do not understand the compare function at the point where ‘-1 : 1’ is included. Please can some one explain to me what the compare function is doing exactly?

 const rows = [
createECG('ad0917d4-e02d-4c46-a5aa-dd83717684e9', '28/06/2022', 'pending'),
createECG('9034124a-2ac8-4d52-8711-ef1351a5c18a', '18/05/2022', 'complete'),
createECG('a2a7a1f4-81a0-4b70-b1e2-ee7a384a1f4f', '01/05/2022', 'pending'),
createECG('e5427e62-5897-4eee-a6a6-8f9925feef96', '21/04/2022', 'complete')
].sort( (a) => (a.status === 'pending' ? -1 : 1));  // The object 'a' has a property called 'status'

how to hide a div on page load with a 5 second delay

so what i want to do is to hide the element for the first 5 seconds the i want the element to show after 5 secs of page load
i have tried many methods but nothing worked yet

here is my code:

 <div id="main_sec_2"></div>

css

#main_sec_2{
    position: relative;
    margin-left: 5px;
    display: none;
    vertical-align: top;
}

js

        function delay () {
        setTimeout( function() { 
window.onload = function() {
  document.getElementById('main_sec_2').style.display = 'inline-block';
}
;}, 500 );
    }

Problem with my slider, it does not appear

I’m trying to make a slider for my website but it does not appear.
I tried to put only the slider code on an html page and it worked but it still doesn’t work on my web page.
Here is the code:

var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("custom-slider");
  if (n > slides.length) {slideIndex = 1}    
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
    slides[i].style.display = "none";  
  }
  slides[slideIndex-1].style.display = "block";  
}
.custom-slider { 
    display: none; 
}
.slide-container {
    max-width: 800px;
    position: relative;
    margin: 50px auto;
}
.prev, .next {
    cursor: pointer;
    position: absolute;        
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: white;
    font-size: 30px;
    background-color: rgba(0,0,0,0);
    transition: background-color 0.6s ease;
}
.prev{ 
    left: 15px; 
}
.next { 
    right: 15px; 
}
.prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.5);
}
.slide-text {
    position: absolute;
    color: #ffffff;
    font-size: 15px;
    padding: 15px;
    bottom: 15px;
    width: 100%;
    text-align: center;
}
.slide-img{ 
    width: 100%; 
    height: 500px;
    object-fit: cover;
    object-position: center;
}
<div class="section3">
        <h1 class="titre" id="realisations">REALISATIONS</h1>
        <div class="slide-container">
            <div class="custom-slider fade">
              <img class="slide-img" src="imgr/Batiment.jpg">
              <div class="slide-text">text1</div>
            </div>
            <div class="custom-slider fade">
              <img class="slide-img" src="imgr/emmanchement2.jpg">
              <div class="slide-text">text2</div>
            </div>
            <div class="custom-slider fade">
              <img class="slide-img" src="imgr/Emmanchement_goupilles.jpg">
              <div class="slide-text">text3</div>
            </div>
            <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
            <a class="next" onclick="plusSlides(1)">&#10095;</a>
          </div>
            
    </div>

If I change the display on the custom-slider, the slider appear but with an image above and one below and when I click on the button for swap pic, the display starts working properly.
I do not understand why
Thanks for the help