Can you disable warning messages in the console?

My student is having trouble with going through the functions of his apps, making sure whether or not it is buggy or not. During this, he had his app coded in a way where he would receive warnings due to a late updated variable.

The problem is, when the console print several things in a short period of time, the whole website lags, especially the current app that is running. This would result into some timing errors from the lag delays since his app is heavily timed based, using setTimeout and setInterval.

We have already established that the warnings are not relevant since it goes away once the variable loads in. I am thinking of suggesting him to just rewrite the code to be more optimized and capable of loading in the variable at the right time.

As far as i know no beyond disabling it each time in the web console
also making stuff time based is also a very very bad idea! have you ever heard of callbacks? there pretty much the bread and butter of ES5 asynchronous functions, also if your student is working with variables beforehand it may be best to pre-allocate it so that that warning may never appear in the first place I’ll show a tiny example to show what i mean

var dog = {
age: 0,
sex: "",
breed: ""
// provides a 1 time update based on pre allocated vars means NO WARNINGS
setTimeout(function() {
dog.age = 5; = "male";
dog.breed = "Collie";
}, 1e3);
// loop checker
setInterval(function() {
}, 1e2)

Don’t know how much of help this will be to you maybe someone will come up with something better, best of luck!

Well, the reason it was time based is because the app that my student is making has loads of animation sequences. He built his own functions and made a massive line of setTimeouts to make the whole sequence.

I’d probably have to see the project then to diagnose what warnings your getting… I was only going off of the info you gave me beforehand you can also delay callbacks by using setTimeouts in functions, that way it won’t be time based what what i was referring to in my last post

function message() {
console.log("this callback has now been executed")
function run(callback) {
console.log("the run sequence has started");
setTimeout(function(){callback()}, 1e3)

maybe something like this may help more? if not I’d be more than happy to look at the project that’s giving you issues

best, varrience

His project is still getting under construction so it may change over time, however, you can probably still find it.

The project link: [App Lab -]

Note: The issue occurs at around 58-59 seconds into the running after the user clicks the startButton or the restartButton. My student specified that the error is caused mainly because of the collision checker that loops along with the deleteElement that runs within the shootBullet function. Scrolling down to 1140 should make of a good start. Thanks in advance.

First, you should get a verified teacher account. That way we know you are not asking us for help that we should not be giving.

Second, you have not specified if this is for the Create Task or not. Right around this time, it becomes important to know that.

Third, this is the kind of project that Game Lab was made to do. Game Lab has code to detect collisions built in.

I will give advice that is not necessarily specific to this project.

Fix the program so it doesn’t throw any warnings.

Don’t use setInterval it isn’t one of the blocks that are available in the palette. That means it may or may not have bugs.

If you want to continue using App Lab create a single timedLoop to do all of the loops. Call functions from that one loop to do the things you want to happen. Setting up as many loops as you have will almost guarantee concurrency issues.

AP CSP doesn’t really address concurrency at all. Concurrency issues can happen for example when you delete something while at the same time checking for a collision with that something. You can’t check for a collision with something that doesn’t exist so an error occurs.

The more loops you have running the more likely they will get shuffled in execution order. If every loop is not independent of the order in which it runs then you have a problem. With a single loop making calls in a specific order, you don’t have that problem. You control the sequence of execution.

With 1244 lines of code (and counting?) There needs to be more design injected into the project. How much code can you remove? There are several functions like enlargeObject that presumably change something’s size. Could all of those functions be a single function?

At line 857 you have //Movements followed by a long line of functions inside functions. How about if you put all the things that need to be done into lists? Then you can iterate through the list and make the calls.

1 Like

@jdonwells i spent basically about half an hour trying to read it and i figured out it is not as it seems @GeovanniS the element gets deleted but not from the list this has huge issues for your program and your guidance was also at the wrong line just because the warning is there doesn’t mean that it isn’t being caused somewhere else in shootBullet doesn’t account for time based deleted elements from your list that your checking later on in the death program, by using this it should probably stop the warning from ever happening

// EDIT: there was another place that was left unchecked when deleted
// Addtional function was added to update other places
// where deleting objects may be necessary
function shootBullet(id, x2, y2, w, h, dur, speed, startPos) {
  var obj = "bullet" + m; m++; appendItem(obstacles, obj);
  button(obj, "");
  setStyle(obj, "background: black; border-radius: 0x; border: 0px;");
  setSize(obj, w, h);
  var x1 = getXPosition(id) + ((getProperty(id, "width") / 2) - ((getProperty(obj, "width") / 2)));
  var y1 = getYPosition(id) + ((getProperty(id, "height") / 2) - ((getProperty(obj, "height") / 2)));
  if (startPos) {
    setPosition(obj, x1, y1);
  var fps = 60;
  if (opt) {
    fps = 30;
    speed = speed * 2;
  x1 = getXPosition(obj);
  y1 = getYPosition(obj);
  var xDiff = x2 - x1;
  var yDiff = y2 - y1;
  var angle = Math.atan2(yDiff, xDiff);
  var xStep = speed * Math.cos(angle);
  var yStep = speed * Math.sin(angle);
  var moveInterval = setInterval(function () {
    if (animate) {
      setPosition(obj, x1 + xStep, y1 + yStep);
      x1 += xStep;
      y1 += yStep;
    } else {
      destroyObject(obstacles, obj);
  }, 1000 / fps);

  setTimeout(function () {
    destroyObject(obstacles, obj);
  }, dur);

function destroyObject(arr, id) {
  for (var i = 0; i < arr.length; i++) {
    if (id === obstacles[i]) {
      removeItem(arr, i);

but for future stuff I’d recommend what Don says you should clean up your code a bit after you patch this or it will become more unmaintainable which is not good practice!

1 Like

Thank you for your input, this project is supposed to be for the AP Create Performance Task. While I do also agree with it being better than in Game Lab, it just happens that our curriculum uses AppLab, being that it is AP Computer Science Principles. While I do agree that my student’s code is still far from clean and optimized, it is only his first year in this class. Thank you again.

Thank you so much for you input. It is true that my student is deleting the element then having it checked in the collision function. Which is what the warning was coming from; the program attempting to run a function with a string that does not exist. I will do my best to explain this to my student, thank you.

Remember that you cannot help your student with the Create Task. It is the only way to make the Create Task fair. If we were allowed to help our students then the students’ performance would be based on the teacher’s abilities and not the students.

From AP Computer Science Principles Student Handouts V.1 page 14

The very best thing you can do is show your class the video here AP CSP Create Task Walkthrough. One of the more important takeaways is that there is both a lower and upper limit to the complexity of the app built. Going beyond that doesn’t help. In my opinion, it probably hinders because isolating your list and algorithm becomes difficult.

1 Like

I am aware of this, it is just a matter of functionality that my student is asking for. It should be no different than asking how an onEvent works or asking if its possible to delete an element. I do not help my students, in a way that it would invalidate the CPT.