3 days agoJavaScript Algorithm: Maximum Edge of a TriangleFinding the maximum possible value of a triangle’s third side — Today, we write a function called nextSide that will accept two arguments, side1 and side2, as integers. You are given the lengths of two sides of a triangle. Assuming that the side lengths are all positive integers, the goal of the function is to output the maximum possible length of…Programming2 min read
4 days agoJavaScript Algorithm: Sum of Polygon AnglesFinding the sum of internal angles in a polygon — Today, we write a function called sumPolygon that will accept one integer, n, as an argument. You are given an n-sided regular polygon. The goal of the function is to calculate and return the total sum of internal angles. We are not going to go into mathematical detail on finding…Java Script1 min read
5 days agoJavaScript Algorithm: The Farm ProblemHow to count legs… — We create a function called animals that accepts three integers: chickens, cows, and pigs. In this problem, you are given the number of chickens, cows, and pigs a farmer has on his farm. The goal of the function is to output the number of legs of all the animals on…Java Script2 min read
Published in JavaScript in Plain English·5 days agoJavaScript Algorithm: Basketball PointsCalculating the number of points scored in a basketball game — We are going to write a program called points that will accept two integers, two_point and three_point. You are counting the total number of points in a basketball game. Within those points, you are given the number of 2-pointers scored and the amount of 3-pointers scored. The goal of the…Java Script2 min read
Published in Level Up Coding·Jun 23JavaScript Basics: Expressions and StatementsWriting a line of code in JavaScript — In JavaScript or any programming language in general, you know that you create a value and apply operators to them to get a new value. A fragment of code that produces a value is an expression. Pretty much every value that is written is considered an expression like an integer…Java Script2 min read
Jun 23JavaScript Basics: BindingsAttaching values to variables — When running a program in JavaScript, it remembers what values go where and when to update them. It updates values by replacing old values with new ones, but how does it do that? JavaScript will have to attach the value to something or the value is meaningless. That is when…Java Script3 min read
Published in JavaScript in Plain English·Jun 23JavaScript Algorithm: ChessboardCreating an 8x8 grid chessboard — Today we are going to create a program that outputs a string representing an 8x8 grid. We will break up that string using newline characters to help build the grid. On a chessboard, the squares alternate between black and blank or white. We do the same for this program, but…Java Script3 min read
Published in Level Up Coding·Jun 22Automatic Type Conversion in JavaScriptHow JavaScript adjusts itself so your program can run (if it runs) — You can add weird calculations to your program and JavaScript will kind of just accept it. console.log(8 * null) // 0 console.log("5" - 1) // 4 console.log( "5" + 1) // "51" console.log("five" * 2) // NaN When an operator is being used by an incorrect type, JavaScript will convert…Java Script3 min read
Jun 22JavaScript Algorithm: Looping A TriangleCreating a half triangle — Today we are going to write a program that will console log a half triangle. The half triangle will need to be seven rows tall and consist of nothing but the # character. Here is an example: # ## ### #### ##### ###### ####### That is what your program should…Java Script1 min read
Published in JavaScript in Plain English·Jun 22JavaScript Basics: Boolean ValuesTrue or False — In JavaScript, there is a way to turn values on or off or make them a yes or a no without using a string to determine this. That is when the Boolean type comes in. In JavaScript, the Boolean type is either true or false. Here is an example of…Java Script3 min read