#### 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 ..

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 ..

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? ..

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") { ..

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 ..

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 ..

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 ..