Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

297
Vistas
What is the propose of using window.location?.search?.split

I need to understand the propose of using window.location?.search?.split('=')[1] and why id takes value of window.location?.search?.split('=')[1]

Code:

function EndScreen() {
  const [score, setScore] = React.useContext(ScoreContext);

  /* console.log('history', window.location?.search?.split('=')[1]); */
  return (
    <div className="EndScreen">
      <h1>Test finished</h1>
      <br></br>
      <h3> You scored:</h3>
      <h1 style={{ fontSize: '70px' }}>
        {score} / {Questions?.length}
      </h1>
      <br></br>
      <br></br>
      <button
        onClick={() =>
          FormService.update({
            id: window.location?.search?.split('=')[1],
            data: { score: score }
          })
          .then(() => {
            alert('Score updated');
          })
          .catch(() => {
            alert('Score did NOT update')
          })
        }
      >
        Apply for job
      </button>
    </div>
  );
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Its for working with querystring:

if your url is , google.com/user/userData?id=123,email=exp@gmail.com

we call user and userData path & id and email are called querystrings

location.search; // Returns:'?id=123,email=exp@gmail.com'

let newArray = location.search.split('=') // Returns:['?id','123',',email','exp@gmail.com'] 

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda