0
我想匹配兩個變量。如何比較javascript中的兩個變量
var this_roll;
和
var last_roll;
我有這樣的代碼,我想要的 「雙贏」 或 「losse」 的輸出。輸出應該是 「雙贏」 如果last_roll
和this_roll
具有相同的價值和 「輸」 如果不是
"use strict";
var x;
var win_losse = 'losse';
var last_roll;
var last_bet;
var this_roll = $('#past')[0].childNodes[9].textContent;
var bet_input = document.getElementById('betAmount').value=x;
var roll_time = $('#banner')[0].childNodes[0].textContent;
var base_bet = 5;
function thisRoll() {
\t console.log(this_roll);
\t if (this_roll == 0) {
\t \t this_roll = 'green';
\t } else if ((this_roll >= 1) && (this_roll <= 7)) {
\t \t this_roll = 'red';
\t } else if ((this_roll >= 8) && (this_roll <= 14)) {
\t \t this_roll = 'black';
\t }
}
function compare() {
\t if (this_roll == last_roll) {
\t \t win_losse = 'win';
\t } else {
\t \t win_losse = 'losse';
\t }
\t console.log(win_lose);
}
function lastRoll() {
\t console.log(this_roll);
\t if (this_roll == 0) {
\t \t last_roll = 'green';
\t } else if ((this_roll >= 1) && (this_roll <= 7)) {
\t \t last_roll = 'red';
\t } else if ((this_roll >= 8) && (this_roll <= 14)) {
\t \t last_roll = 'black';
\t }
}
function bet() {
\t if (win_losse == 'win') {
\t \t x = base_bet;
\t } else if (win_losse == 'losse') {
\t \t x = last_bet * 2;
\t }
}
console.log(x);
*「它似乎沒有工作」*沒有告訴我們任何事情。你得到了什麼結果,你期望得到什麼結果?另外,請將上面各個斷開的部分放到一個[mcve]中,理想情況下是使用Stack Snippets('<>'工具欄按鈕)的** runnable **。 –
*「這將設置this_roll的值」*以下代碼塊中沒有設置this_roll的值。 –
謝謝剛剛看到,我已經改變了它 – cbh1608