2017-08-05 6 views
-1

私はplug.djスクリプトのためにこの関数を書いていました。答えがyesならチャットメッセージを追加しますが、答えがnoの場合は関数を終了するのに問題があります。私はプロのプログラマーではない。JavaScriptでプロンプトの答えが「いいえ」の場合の関数の終了方法は?

コード:

f_votelggr: function (obj){ 
     if (nScript.mehShow) { 
      if (obj.vote != 1) { 
      prompt(obj.user.username + " didn't liked this song! Do you want to alert the users?") 
      if ("yes"); 
      API.sendChat(obj.user.username + "didn't like this song!");        
      } else { 
      return 
      }; 
    }, 
+1

'return'がうまく動作しますが、あなたは現在、私は地獄に行きますdownvoted誰でも何でも – Bergi

答えて

0

はこれを試してみてください:

if ("no"){ 
    return null; 
} 

私は、これはあなたが探しているものであると思います。それは機能を残すでしょう。

編集:

var input = prompt(obj.user.username + " didn't liked this song! Do you want 
    to alert the users?") 
    if (input == "yes"){ 
    API.sendChat(obj.user.username + "didn't like this song!"); 
    }        
    else if{ 
     (input == "no"){ 
     // do stuff here 
     return null; 
    } else { 
     return} 
    }; 
+0

のための' prompt'呼び出しの結果を使用していません。 –

0

あなたはユーザー

var input = prompt(obj.user.username + " didn't liked this song! Do you want 
    to alert the users?") 
    if (input == "yes"){ 
    API.sendChat(obj.user.username + "didn't like this song!"); 
    }        
    else{ 
    return; 
    }; 

から促さ入力を受けるべきであるし、また、あなたはすぐにあなたがいる場合は終了

if ("yes"); 

を持っています。混乱やバグを避けるために;を削除し、{}を使用してください。

0
var input = prompt(obj.user.username + " didn't liked this song! Do you want to alert the users?"); 
input = input.toLowercase(); 
if (input === "yes") { 
    API.sendChat(obj.user.username + "didn't like this song!"); 
} else { 
    return false; 
}; 
+6

コードにコンテキストを追加してください。 – ppperry

+0

plug.djは、曲をプレイしたり、他のユーザーとチャットしたり、オートウォートなどの自動化、DJブースへの参加、ユーザーの参加/離脱の通知、私は助けを求めました、私はこれを大きなものにしようとは考えていません、それはコーディングの楽しさとそれにクールなものを加えるだけです – Icarus

関連する問題