JSFiddle - React, Tailwind, and code Playground
by karlovac
JavaScript
var magazine = "Cultivated who resolution connection motionless did occasional. Journey promise if it colonel. Can all mirth abode nor hills added. Them men does for body pure. Far end not horses remain sister. Mr parish is to he answer roused piqued afford sussex. It abode words began enjoy years no do no. Tried spoil as heart visit blush or. Boy possible blessing sensible set but margaret interest. Off tears are day blind smile alone had. Old unsatiable our now but considered travelling impression. In excuse hardly summer in basket misery. By rent an part need. At wrong of of water those linen. Needed oppose seemed how all. Very mrs shed shew gave you. Oh shutters do removing reserved wandered an. But described questions for recommend advantage belonging estimable had. Pianoforte reasonable as so am inhabiting. Chatty design remark and his abroad figure but its. Inhabit hearing perhaps on ye do no. It maids decay as there he. Smallest on suitable disposed do although blessing he juvenile in. Society or if excited forbade. Here name off yet she long sold easy whom. Differed oh cheerful procured pleasure securing suitable in. Hold rich on an he oh fine. Chapter ability shyness article welcome be do on service.";
var note = "Pay me now or else it will get very silly";
/*
* Returns true if the note can be written with characters
* from magazine.
*/
function ransomNote(magazine, note) {
var magazineLetters = new Object();
for (var i = 0; i<magazine.length; i++) {
var c = magazine.charAt(i);
if (c == " ") {
continue;
}
if (magazineLetters[c] != undefined) {
magazineLetters[c]++;
} else {
magazineLetters[c] = 1;
}
}
for (var i=0; i<note.length; i++) {
var c = note.charAt(i);
if (c == " ") {
continue;
}
if (magazineLetters[c] != undefined) {
if (magazineLetters[c] == 0) {
return false;
...