import { Component, OnInit } from '@angular/core';
import { from } from 'rxjs';
@Component({
selector: 'app-play-match',
templateUrl: './play-match.component.html',
styleUrls: ['./play-match.component.css']
})
export class PlayMatchComponent implements OnInit {
public teams = [
"Annites Football Club","Devans Football CLub", "Marians Football Club",
"Loyolian Football Club","Avian Football Club"
];
public homeTeamSelect: number = Math.floor(Math.random() * this.teams.length);
public opponentTeamSelect:number = Math.floor(Math.random() * this.teams.length);
if (homeTeamSelect:number === opponentTeamSelect:number) {
}
constructor() { }
ngOnInit(): void {
this.loadScript('../assets/js/play.js')
}
public loadScript(url : string){
const body = <HTMLDivElement> document.body;
const script = document.createElement('script');
script.innerHTML = '';
script.src = url;
script.async = false;
script.defer = true;
body.appendChild(script);
}
}
I encountered an issue where the code cannot find the opponentTeamSelect variable in the if area. How do I resolve this error? Please provide me with guidance. I am attempting to generate two random numbers within the range of the team array length and assign two clubs from the array to variables. However, I require the two random numbers to be distinct. Can someone offer a correct solution for this scenario? Thank you.