/    Sign up×
Community /Pin to ProfileBookmark

Help with boolean flow chart

This program takes user input and if the sentence ends in a ? && contains an even amount of characters it will display yes. if it ends in a ! && has a odd number of char then display no.
And displays user input for every other entry.

I know I have to use a loop to write the program but I don’t know what my boolean expression would be.
Please help me write this program! than you

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumOct 02.2020 — @emi2160475#1623840 You can get the amount of characters in a string by the property `length</C> without using a loop. This function should do the job:
<CODE>
`<i>
</i> function checkIt(str) {
if (str.length % 2 == 0 &amp;&amp; str.charAt(str.length - 1) == '?') {
return 'yes';
} else if (str.length % 2 != 0 &amp;&amp; str.charAt(str.length - 1) == '!') {
return 'no';
} else {
return str;
}
}
console.log(checkIt('abc?'))
console.log(checkIt('xyz1!'))
console.log(checkIt('owrnjhoimqwrmh'))<i>
</i>
``
×

Success!

Help @emi2160475 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...