Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
😲 How to Multiply without using 😲 solution in Clear category for Multiply (Intro) by danielsan
import assert from "assert";
// my asterisk key (number eight key) is broken, so I had to solve it without
// typying the asterisk to multiply the numbers
// 😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁😁
function multTwo(firstArgument: number, secondArgument: number): number {
let ultimateResult = 0
for (let firstCounter: number = 0; firstCounter < firstArgument; firstCounter = firstCounter + 1) {
for (let secondCounter = 0; secondCounter < secondArgument; secondCounter = secondCounter + 1) {
ultimateResult = ultimateResult + 1
}
}
return ultimateResult
}
console.log('Example:');
console.log(multTwo(3, 2));
// These "asserts" are used for self-checking
assert.strictEqual(multTwo(3, 2), 6);
assert.strictEqual(multTwo(0, 1), 0);
console.log("Coding complete? Click 'Check' to earn cool rewards!");
April 21, 2020
Comments: