Note that there are some explanatory texts on larger screens.

plurals
  1. PO"[object Object]" in Place of Variable Strings When Used in Alertify Prompts
    primarykey
    data
    text
    <p>I recently switched from regular JavaScript prompts to the jQuery Plugin 'Alertify' prompts. However, when I define a variable as the prompt's response, and use the variable in a later alert, it prints '[object Object]' instead. After a few hours of Googling and testing, I still haven't come up with an answer.</p> <p>This is my code:</p> <pre><code>do { var fullLoop = false; var user = alertify.prompt("What is your name?", function (e, str) { if (e) { user.toUpperCase(); if (str.length === 0) { alertify.alert("Please enter your name."); fullLoop = true; } } else { alertify.alert("Please enter your name."); fullLoop = true; } }, "Name"); do { var bestLoop = false; var best = alertify.prompt("So " + user + ", what is your greatest ability, STRENGTH, SPEED, or SMARTS?", function (e, str) { if (e) { best.toUpperCase(); if (best === "STRENGTH" || best === "SPEED" || best === "SMARTS") { var offset = options.indexOf(best); if (offset != -1) { options.splice(offset, 1); } } else { alert("Please choose either STRENGTH, SPEED, or SMARTS as your greatest ability."); bestLoop = true; } } else { alertify.alert("Please choose either STRENGTH, SPEED, or SMARTS as your greatest ability."); bestLoop = true; } }, "Greatest Ability"); } while (bestLoop); alertify.alert("Great! So " + best + " is yor greatest ability."); } while (fullLoop); </code></pre> <p>You can see the error I'm experiencing <a href="http://jsfiddle.net/Gux22/58/" rel="nofollow">here</a>.</p> <p>I've also noticed that my <code>if</code> statements regarding the strings are ignored, I'm assuming there's a connection, but what is it? I haven't found any bugs, so am I using Alertify incorrectly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload