Pomogite pozhalutsta! ne rabotayet cod

function Cookie() {
this.phrase;
this.getPreduction;
this.eyesRoling;
//this.submitname
this.init = () => {
this.fetchData();
}
this.init();
}
Cookie.prototype.fetchData = function(){
fetch(‘data/cookieData.json’)
.then(cookieData => cookieData.json())
.then(cookieData=>{
console.log(cookieData.preduction);
this.preduction = cookieData.preduction;
this.showCookie(document.querySelector("#cookieHome"));
})
}
let formChecker = (function(){
Cookie.prototype.speak= function(moodvar){
let endFace = this.normalMouth;
switch (moodvar){
case “happy”:
endFace = this.happyMouth;
break;
case “bad”:
endFace = this.normalMouth;
break;
}

Cookie.prototype.getPreduction = function(){
let moodvar = “”;
const chanse = Math.random(); //generates a random number between 0 and 1

//const preductionVariant = this.chanse[Math.floor(Math.random())];
if (chanse <=0.2){
moodvar = happy;
}
else {
if (chanse >0.2 && chanse <0.5) {
moodvar = normal;
}
else {
moodvar = bad;
}
} // I have var preductionVariant
console.log(moodvar);
let preductionVariants = this.preduction.filter(preductions => preduction.mood == moodvar);
let say = preductionVariants[Math.floor(Math.random()*this.preductionVariants.length)];
this.useMouth(say.saying, endFace);
//this.talkBox.innerText = say.saying;
}
}

Cookie.prototype.getName = function() {
let person = prompt(“Please enter your name”);
if (person != 0) {
document.getElementById(“name”).innerHTML =
this.namePicker = person + this.say;
console.log(this.namePicker(“aaaa”));
}
}

Cookie.prototype.useMouth = function(words, mouthType){
this.startMimic(mouthType);
this.eyesRoling();
this.talkBox.innerText = words;
}

Cookie.prototype.showPreduction = function(){
if (this.say > 0 ) {
this.talkBox.innerText= (hey ${this.namePicker} you got ${say.saying});
}
else {
this.talkBox.innerText= “drink more water”;
}
}
Cookie.prototype.charsOnlyTest = function (nameCheck){
let nameCheck = /^[a-zA-z]+$/;
if(nameCheck.test(testStr)){
return true;
}
else {
alert(‘You must use alphabet characters only’);
}
return false;
}
Cookie.prototype.checkForm = function (event){
event.preventDefault();
let submitValues = event.target.querySelector("#name").value;
}

Cookie.prototype.showCookie = function(cookieHolder){
cookieHolder.innerHTML = `



.cls-1{fill:#e2a26d;}.cls-1,.cls-2,.cls-3,.cls-4,.cls-5{stroke:#000;stroke-miterlimit:10;}.cls-2{fill:#f7f7f7;}.cls-3{fill:#0c0000;}.cls-4{fill:none;stroke-width:4px;}.cls-5{fill:#f2f4f7;stroke-width:2px;}.cls-6{font-size:60px;font-family:TimesNewRomanPS-ItalicMT, Times New Roman;font-style:italic;}

100-polyester-yummy-world-xl-fortune-cookie-plush-1_2048x











<path id=“happy_mought” class = "hidden"class=“cls-5” d=“M268,282.53H414a0,0,0,0,1,0,0V296.2a23,23,0,0,1-23,23H288a20,20,0,0,1-20-20V282.53A0,0,0,0,1,268,282.53Z”/>

Fortune Cookie!





enter your name




your preduction


“press me”

`; }

//let submitname = onevent.querySelector("#name").value;
this.talkBox = document.querySelector("#cookieVoice");
this.clickButton = document.querySelector("#cookieButton");

Cookie.prototype.initializeFace = function(){ // fine
this.mouth = document.querySelector("#mouth");
this.normalMouth = document.querySelector("#normal_mouth");
this.happyMouth = document.querySelector("#happy_mouth");

  this.normallEye_left = document.querySelector("#right_eye .normall eye");
  this.normallEye_right = document.querySelector("#left_eye .normall eye");
  this.Eyes = [this.normallEye_left, this.normallEye_right]; // my var for both eyes
  this.EyesAnimation(); //  I have to provide my f for Eyes; when I will fix preduction F place it there;

}
Cookie.prototype.MouhtAnimation = function(){ // fine;
this.normalMouth.classList.add(“hidden”);
this.happyMouth.classList.add(“hidden”);
}
Cookie.prototype.changeExpression = function(mouthType){
this.MouhtAnimation();
(mouthType).classList.remove(“hidden”); //remove hidden by command;
}
Cookie.prototype.startMimic = function(mouthType){
this.MouhtAnimation();
this.normalMouth.classList.remove(“hidden”);
this.happyMouth.classList.add(“talking”);
clearTimeout(this.talkTimer);
this.talkTimer = setTimeout(() => this.stopTalking(mouthType), 3000);
}
Cookie.prototype.stopMimic = function(mouthType){
this.MouhtAnimation();
this.changeExpression(mouthType);
this.mouth.classList.remove(“talking”);
}

Cookie.prototype.eyesRoling = function(){
this.EyesAnimation();
this.Eyes.forEach(eye => eye.classList.add(“eye_roll”));
this.rollTimeout = setTimeout(() => this.EyesAnimation(), 3000);
}
return{
initForm: function(userForm){
userForm.addEventListener(“submit”, checkForm);
}
}
})();
let myfortuneCookie;
window.onload = function(){
myfortuneCookie = new Cookie();

}

С такой формулировкой никто тебе не поможет. Прочти как оформлять вопросы Как формулировать вопрос, подсвечивать код, благодарить и поправь соответственно свой пост.

3 симпатии