-3

I get a syntax error concerning line code matches++ : get error notification line 119 unexpected identifier? Fixed some errors, but still a syntax error appears.`

Syntax error occurs at line code let matches =0;

I have simpel add semicolon to fix some syntax and also have changed newprofile where there is different of the capital.Consistent naming.

const allNewProfiles = mockData;
let matches = 0;
for (let anewProfile of allNewProfiles)
'use strict';

const mockData = require('./mockData.js').data;
//console.log(mockData);

// Your code here
let newProfile = [];
console.log("Hello, welcome at Winc dating-app. Create new account by filling out the questions below and our matching wil help you to find real love");

// First name            
let firstName = "" ;
while (firstName.length <= 1 || !isNaN (firstName)) {
  firstName= prompt("What is your first name?");
  if (firstName.length <= 1 ) alert ("Enter your first name please to continue. Your first name can not be empty.");
  if (!isNaN(firstName)) alert("Enter no number please");
}

newProfile.first_name = firstName;

// Last name
let lastName = "" ;
while (lastName.length <= 1 || !isNaN(lastName)) {
  lastName= prompt("What is your last name?");
  if (lastName.length <= 1 ) alert ("Enter your last name please to continue. Your last name can not be empty.");
  if (!isNaN(firstName)) alert("Enter no number please");
}

newProfile.last_name = lastName;

// Age
let age= 0;
while (age < 18 || !Number(age)) {
  age= prompt("What is your age?");
if(!Number(age)) alert("Please you need to enter numbers ");
 if(age < 18) alert("you have to be 18+ to create account"); 
}

newProfile.age = age;

// Gender 
let gender = "";
while (true) {
  gender = prompt("What's your gender? (type: F for female, M for male or X for all other genders");
  if (gender === "M" || gender === "F" || gender === "X") {
    break;
  }
  }
newProfile.gender = gender;

// Gender interest
let genderInterest = "";
while (true) {
  genderInterest = prompt("What gender are you interested in dating? (type: F for female, M for male, X for all other genders )");
  if (genderInterest === "M") {
    break;
  }
  if (genderInterest === "F") {
    break;
  }
  if (genderInterest === "X") {
    break;
  } 
  
  }
  


newProfile.gender_interest = genderInterest;

let location = "";
while (true) {
  location = prompt("Are you from the 1.city or 2.rural? Please select which one of the two is your location!");
  if (location === "city") {
    break;
  }
  if (location === "rural") {
    break;

  }
}

newProfile.location = location;

// Minimum age interest
let interestForMinAge = 0;
while (interestForMinAge < 18 || Number.isNaN(interestForMinAge)) {
  interestForMinAge = prompt("What's the minimum from age 18+ you are interested to date?")
  interestForMinAge = Number(interestForMinAge);
}
newProfile.interest_for_min_age = interestForMinAge;

//Maximum age interest
let interestForMaxAge = 0;
while (interestForMaxAge < 18 || Number.isNaN(interestForMaxAge) || (interestForMaxAge <= interestForMaxAge)) {
  interestForMaxAge = prompt("What is for you the maximum age you want to date? ")
  interestForMaxAge = Number(interestForMaxAge);
}
newProfile.interest_for_max_age = interestForMaxAge;

console.log(`${newProfile.first_name} Thank you for filling out your information! Look below at your answers. You are now sign-up for Winc datingapp <3.`);

////Here the matching is happen. Matching the newProfile age/ User age interest: higher or equal to, lower or equal user for interest for min/max age. Gender profile to match with gender users. Than also to match the interest with the newProfile gender
const allNewProfiles = mockData;
let matches = 0;
for (let anewProfile of allNewProfiles) {
  
  if (((newProfile.age >= newProfile.interest_for_min_age && newProfile.age <= anewProfile.interest_for_max_age) && (anewProfile.age >= newProfile.interest_for_min_age && anewProfile.age <= newProfile.interest_for_max_age)
      ) && 
   (
     ( 
      (newProfile.gender_interest === "F" && newProfile.gender === "F") || (anewProfile.gender_interest === "M" && newProfile.gender === "M") || (anewProfile.gender_interest === "X" && newProfile.gender === "X") || (anewProfile.gender_interest === "M" && (newProfile.gender === "X" || newProfile.gender === "F"))
    ) && 
     
      (newProfile.gender_interest === "F" && anewProfile.gender === "F") || (newProfile.gender_interest === "M" && anewProfile.gender === "M") || (newProfile.gender_interest === "X" && anewProfile.gender === "X") ||  (anewProfile.gender === "F" && anewProfile.gender === "M")          
    && 
       (newProfile.location === anewProfile.location) 
//search matches
    matches++
    console.log("New match found!");
    console.table(anewProfile);

  }
}

if (matches === 0) {
  console.log("Matching not found yet. Try again to find your match!");
} else {
  console.log(`Yes you have a match! See the collecting ${matches} found match(es)`);
}
Yass
  • 1
  • 2
  • 1
    Please post the relevant code here, as links can break and therefore become useless to future readers. But I suspect the if-statement above `matches++` is missing its closing curly-brace (`}`). – mykaf Aug 28 '23 at 15:03
  • 1
    Either that or the `if` outer parens are not properly balanced; that giant expression is a mess and should be split out into separate functions. – Pointy Aug 28 '23 at 15:09
  • 1
    I'd say it's missing a closing parenthesis at line 117 and then curly braces around lines 119 to 121. I strongly advise you to avoid such long if statement. Try to regroup your condition into intermediate variables to make your code more readable. – Emilien Aug 28 '23 at 15:09
  • 1
    Use a good IDE, it will help you avoid simple errors like this. – Barmar Aug 28 '23 at 15:21

0 Answers0