-
Notifications
You must be signed in to change notification settings - Fork 326
BloomTech Prompt Examples
Role: “Act as…”
Context : Any required background information.
Directive: What is the exact goal that needs to be accomplished?
Act as my javascript tutor.
I need to master the .forEach() method. I want to be able to use it in projects and code.
Breakdown the key elements of the loop and show me examples showcasing what I need to know.
Act as my coding textbook.
I need to master the following problem:
/**
PROBLEM 4: Given an array of numbers, use the .forEach array method to find the sum of all the numbers in the array
**/
const numbersToSum = [1, 2, 3, 4, 5]; let sum = 0;
//ENTER YOUR CODE HERE
I need to master using .forEach() in all scenarios.
Generate 3 exercises for me to better understand .forEach() and practice.
Act as my coding teacher.
I solved the problem above and came up with the following solution:
/**
PROBLEM 4: Given an array of numbers, use the .forEach array method to find the sum of all the numbers in the array
**/
const numbersToSum = [1, 2, 3, 4, 5]; let sum = 0;
numberToSum.foreach((num, index) => { console.log(num); })
//ENTER YOUR CODE HERE
Is this correct? What can I do better?