#### Category : logic

Let’s walk through a few examples of logic that will calculate which value is smaller: The basic if-conditional: let a = 6; let b = 2; let smaller = null; if(a < b) { smaller = a; } else { smaller = b; } console.log(smaller) Using a Ternary Conditional: let smaller = a < b ..

Read more I’m practicing some programming logic with a challenge that a friend shared with me. Here’s the problem: Write a script that takes an integer n as the numbers of rows and columns of a matrix and take the element list of the matrix. Example: n=3 matrix = [[11 2 4], [4 5 6], [10 8 ..

Read more

Hello i have regex like this ^[d]{4,5}([;]d{4,5})*\$|(^[d]{4,4}([:]d{4,5})\$)|^[d]{4,5}(s[;]sd{4,5})*\$|(^[d]{4,4}(s[:]sd{4,5})\$) I need effect like this: 12345 : 12345 – allowed 12345 : 1234 – not allowed 12345 : 12344 – not allowed 1234 : 1235 – allowed 1234 : 12345 – allowed Generally – left <= right Rest can be stay Someone know how to resolve this problem? ..

Read more

I am working with OR gate logic to compare a few data (LHS) with a common data (RHS). My logic is currently working fine, but I would like to know if there’s a better approach to do this. if (data1 == "compareData" || data2 == "compareData" || data3 == "compareData" || data4 == "compareData") { ..

Read more

I’m working in angular trying to create a logic for Fill in the blanks where the user can input text in textarea and then make as many blanks as they want from a sentence. For example: "This is a bowl of fruit" If the user decides to make "bowl" as a blank they simply would ..

Read more I have a Delivery system that I made using Laravel + Vuejs, I’m facing a logic problem that I’m thinking of many ways to solve this but all is not good. I have a function that everytime the user change the quantity of the cart, all my options need to double their values because is ..

Read more

I made a random password generator app and I want to show the last three generated passwords on a View: function generatePass() { let pass = ” for(let i = 0,n = charset.length; i < size; i++) { pass += charset.charAt(Math.floor(Math.random() * n)) } setPassword(pass); — <View style={styles.area}> <Text style={styles.lastPasswordsTitle}>Last generated passwords</Text> <Text style={styles.lastPasswords}>Pass1</Text> <Text ..

Read more

I have a checkbox and want to say this checkbox: if (for example) “Einzelberatung BU” is selected and you want to select another field with the term “Einzelberatung…” then the field “Komplettes Finanzkonzept” automatically should be selected and the both other fields should be deselected. As you can see I’m an absolute beginner with javascript. ..

Read more

I tried running this snippet of code for which I tried consoling the i value inside setTimeOut() function and the o/p i got is 5 for 5 times with a time interval of 3 seconds each, can anyone please explain this snippet? for (var i = 0; i < 5; i++) { console.log(i); setTimeout(function() { ..

Read more There is tax called 70%-30%. Base price of product will be part in 70% and 30%. And tax on 70% amount will be 5% and on 30% will be 18%. Here is Image sample calculated. Now calculation is required reverse. We have 24000.00273 and tax information. need Base amount to be calculate. We have tried ..

Read more