Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

243
Views
React - Expected an assignment or function call

I'm new with reactjs and I got a little problem. I'm getting an error: Expect an assignment or function call. Is referring to the User function, but I do call that function below when I'm creating a new object. How can I fix this?

import React from 'react';
import '../css/style.css';

export function Form(){

    let users = [];

    function User(name, surname, age, email, password){
        this.name = name;
        this.surname = surname,
        this.age = age,
        this.email = email,
        this.password = password
    }

    function formValues(){
        let name = document.getElementById("name").value;
        let surname = document.getElementById("surname").value;
        let age = document.getElementById("age").value;
        let email = document.getElementById("email").value;
        let pwd = document.getElementById("password").value;

        var newUser = new User(name, surname,age, email, pwd);

        users.push(newUser);
        console.log(users);
    }


    return(
        <div id = "form">
            <h2>Sign up today, for free!</h2>
            <input type="text" id = "name" placeholder = "Name" required/>
            <input type="text" id = "surname" placeholder = "Surname" required/>
            <input type="number" id = "age" placeholder = "Age" required />
            <input type="email" id = "email" placeholder = "Email" required/>
            <input type="password" id = "password" placeholder = "Password" required/>
            <button id = "sign-up" onClick={() => formValues()}>Sign Up</button>
        </div>
    )
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your function isn't using semi-colons to end the expressions.

function User(name, surname, age, email, password) {
  this.name = name;
  this.surname = surname;
  this.age = age;
  this.email = email;
  this.password = password;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!